473,385 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Handling Custom Errors 401.2

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
Nov 19 '05 #1
13 5795
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" <na********@hotmail.com> wrote in message
news:O8**************@TK2MSFTNGP15.phx.gbl...
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

Nov 19 '05 #2
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" <na********@hotmail.com> wrote in message
news:O8**************@TK2MSFTNGP15.phx.gbl...
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

Nov 19 '05 #3
Fixed it!
forgot it was C#
I for got to add the Handler
"Patrick.O.Ige" <na********@hotmail.com> wrote in message
news:Ob*************@TK2MSFTNGP15.phx.gbl...
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" <na********@hotmail.com> wrote in message
news:O8**************@TK2MSFTNGP15.phx.gbl...
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


Nov 19 '05 #4
Fixed it!
forgot it was C#
I for got to add the Handler
"Patrick.O.Ige" <na********@hotmail.com> wrote in message
news:Ob*************@TK2MSFTNGP15.phx.gbl...
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" <na********@hotmail.com> wrote in message
news:O8**************@TK2MSFTNGP15.phx.gbl...
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


Nov 19 '05 #5
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" <na********@hotmail.com> wrote in message
news:Ob*************@TK2MSFTNGP15.phx.gbl...
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" <na********@hotmail.com> wrote in message
news:O8**************@TK2MSFTNGP15.phx.gbl...
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


Nov 19 '05 #6
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" <na********@hotmail.com> wrote in message
news:Ob*************@TK2MSFTNGP15.phx.gbl...
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" <na********@hotmail.com> wrote in message
news:O8**************@TK2MSFTNGP15.phx.gbl...
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


Nov 19 '05 #7
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 ***
Nov 19 '05 #8
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 ***
Nov 19 '05 #9
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 ***
Nov 19 '05 #10
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" <na********@hotmail.com> wrote in message
news:Oj**************@TK2MSFTNGP10.phx.gbl...
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

Nov 19 '05 #11
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 ***
Nov 19 '05 #12
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 ***
Nov 19 '05 #13
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" <na********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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 ***

Nov 19 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Master of C++ | last post by:
Hi, I am writing a simulation package in C++, and so far I've written about 8000 lines of code and have about 30 classes. I haven't used C++ exceptions so far (for various reasons). The only two...
2
by: Steve Jorgensen | last post by:
When writing VB or VBA code that works with databases or other external libraries that cannot be trusted to automatically do the right thing when references to their objects are arbitrarily...
21
by: Anthony England | last post by:
Everyone knows that global variables get re-set in an mdb when an un-handled error is encountered, but it seems that this also happens when the variable is defined as private at form-level. So...
4
by: aaj | last post by:
Hi all I have an automated application, that runs in the middle of the night. If certain 'non system' errors occur (things like malformed files, missing files etc..), I send an automatic Email...
2
by: Rajeev Soni | last post by:
Hi, Considering the scenario for handling exceptions in Web Application where we have Presentation layer, Business layer and Data Access layer; if there any exception is occurred in DAL, what is...
4
by: Paul | last post by:
I have written a custom dll that I put inside the /bin directory of a production IIS server. Inside the config file of the web application i have added the following setting: <httpModules>...
1
by: michaeltorus | last post by:
Hi I'm currently designing a new web application in .Net. I've pretty covered everything, apart from error handling. There seems to be a few different way to do this, but something I've read...
4
by: James Radke | last post by:
Hello, I am looking for guidance on best practices to incorporate effective and complete error handling in an application written in VB.NET. If I have the following function in a class module...
2
by: tshad | last post by:
This has been driving me crazy. I have been trying to get the error handling working on my system and can get parts of it working and others won't work at all. I found that you can't access...
7
by: Jason Kester | last post by:
Best I can tell, there are three basic ways you can deal with global error handling in ASP.NET. Namely: 1. Derive all your pages from a custom Page class, and override OnError() 2. Specify a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.