Sending a 403 response

  • Thread starter Thread starter Martin Robins
  • Start date Start date
M

Martin Robins

I have an application which uses Windows Authentication to identify users
and ensure that they are on a domain. Once access is granted at this level,
I then check their login name against a database of validated users to
determine whether the particular user can actually use the system.

If a user is not in the database, I want to respond with the same error page
as would be seen if they failed the windows authentication; the 403
forbidden access page. I have tried setting Response.StatusCode to 403 and
then calling Response.End() but this simply leaves the client with an empty
page. How do I have IIS automatically divert to whatever the current 403
page on the site is?

Cheers.
 
re:
I have tried setting Response.StatusCode to 403 and then calling Response.End() but this simply
leaves the client with an empty page.
How do I have IIS automatically divert to whatever the current 403 page on the site is?

You could copy the 403 page to your application,
from drive:\WINDOWS\Help\iisHelp\common , and response.redirect to it
if the client fails authentication in the database of validated users.

You could also raise an exception, based on the client not being found in
your database of validated users, and response.redirect based on that.





Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 
Am I to take it then that there is no built in support for this?

(BTW: ASP.net 2.0)
 
Raising an exception, based on the client not being found in your database
of validated users, and response.redirecting based on that is an ASP.NET 2.0
way of doing what you want to do.

ASP.NET doesn't have anything to do with HTTP Status Codes. IIS does.

In order for an IIS status code exception to be redirected to a custom page,
it has to be handled by IIS itself.



Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 
Back
Top