+ Reply to Thread
Page 4 of 5 FirstFirst ... 2 3 4 5 LastLast
Results 31 to 40 of 47

Thread: Throw HTTP Status Code error

  1. #31
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    1,724
    Blog Entries
    10
    Rep Power
    11

    I don't suppose it could be because I'm running it from Visual Studio, could it? That doesn't use IIS, does it?

    Does running it from Visual Studio allow for status codes?

  2. #32
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    1,724
    Blog Entries
    10
    Rep Power
    11

    Quote Originally Posted by jmurrayhead View Post
    What do you see?
    I just see the page as normal with the message from my event handler at the top of the page:
    Code:
    403PermissionModule Node: Beginning of Request
    

  3. #33
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,347
    Blog Entries
    9
    Rep Power
    19

    Quote Originally Posted by richyrich View Post
    I don't suppose it could be because I'm running it from Visual Studio, could it? That doesn't use IIS, does it?

    Does running it from Visual Studio allow for status codes?
    I don't recall...I could have sworn that VS still gives me a default 403 authorization page.

    Quote Originally Posted by richyrich View Post
    I just see the page as normal with the message from my event handler at the top of the page:
    Code:
    403PermissionModule Node: Beginning of Request
    
    Have you tried setting up a custom error page for 403 errors?
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  4. #34
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    1,724
    Blog Entries
    10
    Rep Power
    11

    Quote Originally Posted by JmurrayHead
    Have you tried setting up a custom error page for 403 errors?
    No, I haven't yet. Will give it a go and see what happens.

  5. #35
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    1,724
    Blog Entries
    10
    Rep Power
    11

    Nope...Doesn't work...
    Code:
        <customErrors mode="On" defaultRedirect="default.aspx">
          <error statusCode="403" redirect="NoAccess.htm" />
          <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
    
    It doesn't redirect to NoAccess.htm.

    If I cause a 404 it redirects fine...Argh...This is very annoying...Why can't you do this?

    FormsAuthentication fires a 302 response if you try and access a page when not logged in, even on pages that do not exist (I just tried in Fiddler), so FormsAuthentication can fire back a status code before the custom error handler in web.config. So, why can't I fire a 403 response on pages when the user doesn't have permission to view a page?

    Just doesn't make sense..

  6. #36
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,347
    Blog Entries
    9
    Rep Power
    19

    Try simply checking the status code and then use Response.Redirect to NoAccess.htm.
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  7. #37
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    1,724
    Blog Entries
    10
    Rep Power
    11

    Kind of misses the point then though J. I could already get it to redirect if the permissions failed anyway..I just thought it might be an idea to get it to go by status code.

    I guess MS decided that wouldn't be a good idea and made it impossible to do...

    The basic problem:-
    To check if the user is authenticated you have to wait until Application AuthorizeRequest event.
    If you change the status code during this event, it doesn't affect the page request sent back to the user.

    ergo...It's impossible to achieve this..

  8. #38
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    1,724
    Blog Entries
    10
    Rep Power
    11

    I did find this article. See the second comment.

    Could this be the issue I'm having a problem with? Is it something to do with the page request and web server setting the status code.

    At which point is the status code set?

    Gonna try playing around with the status codes in the different events and see what happens.

  9. #39
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,347
    Blog Entries
    9
    Rep Power
    19
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  10. #40
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    1,724
    Blog Entries
    10
    Rep Power
    11

    I'm going to give up on this idea, I think.

    It is returning a status code of 403 but then it's not redirecting based on the custom errors in web.config.

    I set application.Response.StatusCode=403 in the AuthenticateRequest event and when I check HttpContext.Current.Response.StatusCode it equals 403 but it still just shows the page as normal.

+ Reply to Thread
Page 4 of 5 FirstFirst ... 2 3 4 5 LastLast

Similar Threads

  1. http://conception-2-school.com/forums/
    By jmurrayhead in forum Website Reviews
    Replies: 15
    Last Post: April 22nd, 2009, 12:11 PM
  2. Need PHP/SQL code help...to fix written code
    By honeybeeaz in forum PHP Development
    Replies: 10
    Last Post: November 11th, 2008, 03:22 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO