Can't set 403 status?

  • Thread starter Thread starter Steve - DND
  • Start date Start date
S

Steve - DND

When certain conditions are met on my ASPX pages, I want to set the status
of the response to 403, and have it handled by the custom 403 page I have
specified in my web.config file. Unfortunately it's not working. In my ASPX
page I have:

....
Response.StatusCode = 403;
....

In my web.config, I have:

<customErrors mode="On">
<error statusCode="403" redirect="403.aspx"/>
<error statusCode="404" redirect="404.aspx"/>
</customErrors>

If I do a Response.Write(Response.StatusCode) it says that it's 403, but I
never get redirected to the custom 403 page, it just continues loading the
page normally. Any thoughts?

Thanks,
Steve
 
Hi Steve,
In the Internet Service Manager MMC, right-click the Web
site, and then select Properties.
Click the Custom Errors tab.
Choose the 403 HTTP error.
Edit Properties and give the file you want to display
Click OK, and then click Apply.

Hope that helps
Have a great day :)
R. Pooran Prasad
Itreya Technologies Pvt Ltd.,
Mail: (e-mail address removed)
Phone(Off) : +91 80 5200179 Extn: 42
Mobile: +91 98860 29578
 
I know how to change it via the IIS snap-in, but what I'm wondering is why
it doesn't work through the web.config file? Isn't the idea behind being
able to specify error redirects in the customErrors block, that you *don't*
have to use the IIS snap-in?

Steve
 
I should also note that this is all irrelevant, since even though I'm
setting Response.StatusCode = 403, I'm still getting my normal ASPX page
returned, *not* my custom one, and *not* the IIS default 403 handler.

Steve
 
Back
Top