Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Handling Custom Errors 401.2

Reply
Thread Tools

Handling Custom Errors 401.2

 
 
Patrick.O.Ige
Guest
Posts: n/a
 
      07-26-2005
How can i get to redirect users if the get error 401.2 to another page?
I guess i should be possible to do it in Global.asax?
Or are there any better ways around it..
Any better solutions in ASP.NET 2.0?
Patrick


 
Reply With Quote
 
 
 
 
Patrick.O.Ige
Guest
Posts: n/a
 
      07-26-2005
I'm trying to use this code:-

Private Sub Global_EndRequest(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.EndRequest
If Response.StatusCode = 401 AndAlso Request.IsAuthenticated = True Then
Response.ClearContent()
Server.Execute("http://server/tests.aspx")
End If
End Sub

WHICH I CONVERTED TO C# but it seems not to fire don't know what 'm
missing
Thanks
private void Global_EndRequest(object sender, System.EventArgs e)

{

if (Response.StatusCode == 401 && Request.IsAuthenticated == true)

{

Response.ClearContent();

Server.Execute("http://server/tests.aspx");



}

}

"Patrick.O.Ige" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How can i get to redirect users if the get error 401.2 to another page?
> I guess i should be possible to do it in Global.asax?
> Or are there any better ways around it..
> Any better solutions in ASP.NET 2.0?
> Patrick
>
>



 
Reply With Quote
 
 
 
 
Patrick.O.Ige
Guest
Posts: n/a
 
      07-26-2005
Fixed it!
forgot it was C#
I for got to add the Handler


"Patrick.O.Ige" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm trying to use this code:-
>
> Private Sub Global_EndRequest(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.EndRequest
> If Response.StatusCode = 401 AndAlso Request.IsAuthenticated = True Then
> Response.ClearContent()
> Server.Execute("http://server/tests.aspx")
> End If
> End Sub
>
> WHICH I CONVERTED TO C# but it seems not to fire don't know what 'm
> missing
> Thanks
> private void Global_EndRequest(object sender, System.EventArgs e)
>
> {
>
> if (Response.StatusCode == 401 && Request.IsAuthenticated == true)
>
> {
>
> Response.ClearContent();
>
> Server.Execute("http://server/tests.aspx");
>
>
>
> }
>
> }
>
> "Patrick.O.Ige" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > How can i get to redirect users if the get error 401.2 to another page?
> > I guess i should be possible to do it in Global.asax?
> > Or are there any better ways around it..
> > Any better solutions in ASP.NET 2.0?
> > Patrick
> >
> >

>
>



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      07-26-2005
Hi, Patrick.

See my reply in the "Well global.asax didn't work as well as hoped" thread.

There's sample code there.



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espaņol
Ven, y hablemos de ASP.NET...
======================

"Patrick.O.Ige" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm trying to use this code:-
>
> Private Sub Global_EndRequest(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.EndRequest
> If Response.StatusCode = 401 AndAlso Request.IsAuthenticated = True Then
> Response.ClearContent()
> Server.Execute("http://server/tests.aspx")
> End If
> End Sub
>
> WHICH I CONVERTED TO C# but it seems not to fire don't know what 'm
> missing
> Thanks
> private void Global_EndRequest(object sender, System.EventArgs e)
>
> {
>
> if (Response.StatusCode == 401 && Request.IsAuthenticated == true)
>
> {
>
> Response.ClearContent();
>
> Server.Execute("http://server/tests.aspx");
>
>
>
> }
>
> }
>
> "Patrick.O.Ige" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> How can i get to redirect users if the get error 401.2 to another page?
>> I guess i should be possible to do it in Global.asax?
>> Or are there any better ways around it..
>> Any better solutions in ASP.NET 2.0?
>> Patrick
>>
>>

>
>



 
Reply With Quote
 
Patrick Olurotimi Ige
Guest
Posts: n/a
 
      07-26-2005
Thx Juan i had a brief look and it seems intersting and clean..
Will give that a try,
Thx
Patrick

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
Patrick Olurotimi Ige
Guest
Posts: n/a
 
      08-17-2005
Thx Juan for the hint but with the code you posted i can't capture the
HTTPEXCEPTION 401 but exception 404 works if i try browsing an ASPX page
that doesn;'t exist

I have included:-

Case 401
errMessage &= "You are not authorised to view this page."

to loop through but it doesn't seem to work.

I have Windows Integrated
Auth and Basic Auth with a selected DOMAIN.

Any clue why it isn't working?
Thanks


*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      08-17-2005
Hi, Patrick.

IIS defines a number of different 401 errors
that indicate a more specific cause of the error. :

401 - Access denied.
401.1 - Logon failed.
401.2 - Logon failed due to server configuration.
401.3 - Unauthorized due to ACL on resource.
401.4 - Authorization failed by filter.
401.5 - Authorization failed by ISAPI/CGI application.
401.7 - Access denied by URL authorization policy on the Web server.
This last error code is specific to IIS 6.0.

It might be that you have to take *those* into consideration
if you want a *specific* error code captured.

I'd try using 401.1 to test catching a "logon failed" exception

Mind you, it could very well be that Windows Integrated Authentication
preempts any IIS authorization scheme.

Maybe testing if the 401 exception works with Forms Authentication would
help us find out if Windows Authentication does preempt IIS's authentication.





Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espaņol
Ven, y hablemos de ASP.NET...
======================

"Patrick Olurotimi Ige" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thx Juan for the hint but with the code you posted i can't capture the
> HTTPEXCEPTION 401 but exception 404 works if i try browsing an ASPX page
> that doesn;'t exist
>
> I have included:-
>
> Case 401
> errMessage &= "You are not authorised to view this page."
>
> to loop through but it doesn't seem to work.
>
> I have Windows Integrated
> Auth and Basic Auth with a selected DOMAIN.
>
> Any clue why it isn't working?
> Thanks



 
Reply With Quote
 
Patrick Olurotimi Ige
Guest
Posts: n/a
 
      08-17-2005
Thanks Juan
Wow i didn't know the status code were this lot...
I was actually thinking of looking through specific ones but i taught
401 will do since i just wnated to look in ACCESS DENIED error..becos i
got it working before but when i came across your solution it was more
cleaner..
I would actually test it for both FORMS AUTH and WINDOWS AUTH and feed
you back.
Patrick


*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
Patrick Olurotimi Ige
Guest
Posts: n/a
 
      08-18-2005
Hi Juan...
I don;t think by adding 401.1 or 401.3 would do the trick
I tried testing with those but no luck..
404 works fine
And i know i get the ACCESS DENIED Error message 401.3 for example
And incase i use IIS version 5
Patrick



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      08-18-2005
Thanks for testing this out, Patrick.
Now we know a bit more than before ...




Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espaņol
Ven, y hablemos de ASP.NET...
======================

"Patrick Olurotimi Ige" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi Juan...
> I don;t think by adding 401.1 or 401.3 would do the trick
> I tried testing with those but no luck..
> 404 works fine
> And i know i get the ACCESS DENIED Error message 401.3 for example
> And incase i use IIS version 5
> Patrick
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Handling Errors in a custom page ThunderMusic ASP .Net 0 09-20-2006 05:22 PM
What is the best way for handling Errors & giving Custom Error mes =?Utf-8?B?U3VoYXMgVmVuZ2lsYXQ=?= ASP .Net 0 07-21-2006 12:22 PM
Handling errors and not redirecting to a custom error page =?Utf-8?B?Sm9yZ2UgTWF0b3M=?= ASP .Net 2 10-29-2004 06:17 PM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM



Advertisments