The above module maps to the <httpErrors /> configuration section that allows you to define your own custom paths to errors and exceptions that might occur in your applicaiton.
So I believe the main reason for what was happening is that, you defined a module that has been already defined for you with the same name.
Either you remove the original module (which I don't recommend) through the <remove name="CustomErrorModule" /> element or simply use a different Name for the module you are registering!
This is something I've been chasing for quite some time now - the ability for asp.net to produce a 404 response code, and redirect to a friendly page.
I've replicated your code (I was previously doing something similar in global.asax.cs); problem I've got is that when you put an event hander on context.Error, the Application_OnAuthenticateRequest hasn't fired - so you don't have a session (context.Session
= null). If I do a Server.Transfer, it goes to a friendly error page which inherits from a Master page that contains some basic functionality that reads the session, and it bombs out.
There *is* a session at this stage, I don't suppose you know of an alternative way of picking it up?
haidar_bilal
All-Star
45609 Points
8730 Posts
MVP
Re: Custom 404 Error via iHTTPHandler
Jul 16, 2008 09:27 AM|LINK
Just my 2 $ in here :)
IIS 7.0 ships with a native module called CustomErrorModule that can be located inside the applicationHost.config file as follows:
<add name="CustomErrorModule" image="%windir%\System32\inetsrv\custerr.dll" />
The above module maps to the <httpErrors /> configuration section that allows you to define your own custom paths to errors and exceptions that might occur in your applicaiton.
So I believe the main reason for what was happening is that, you defined a module that has been already defined for you with the same name.
Either you remove the original module (which I don't recommend) through the <remove name="CustomErrorModule" /> element or simply use a different Name for the module you are registering!
Hope this clarifies the problem more!
Thanks
Professional ASP.NET 3.5 Security, Membership, and Role Management with C# and VB
Dunc_nz
Member
17 Points
4 Posts
Re: Custom 404 Error via iHTTPHandler
Jul 18, 2008 03:19 PM|LINK
Hi,
This is something I've been chasing for quite some time now - the ability for asp.net to produce a 404 response code, and redirect to a friendly page.
I've replicated your code (I was previously doing something similar in global.asax.cs); problem I've got is that when you put an event hander on context.Error, the Application_OnAuthenticateRequest hasn't fired - so you don't have a session (context.Session = null). If I do a Server.Transfer, it goes to a friendly error page which inherits from a Master page that contains some basic functionality that reads the session, and it bombs out.
There *is* a session at this stage, I don't suppose you know of an alternative way of picking it up?
Thanks in advance,
Duncan
http://www.fluidfoundation.com
http://www.fluidstyle.co.uk
http://www.fluideating.co.uk
NicheTank
Member
14 Points
2 Posts
Re: Custom 404 Error via iHTTPHandlerModule and EventHandler
Jul 18, 2008 11:17 PM|LINK
I tried running this and it worked for me locally but not on a shared host. It turned out to be a permissions issue with reading the web.config.
Niche Tank
http://www.nichetank.com
vikas rathee
Member
6 Points
11 Posts
Re: Custom 404 Error via iHTTPHandler
Sep 27, 2011 12:44 PM|LINK
Could you please solve this issue. http://forums.asp.net/p/1724466/4614255.aspx
Please let me know..