In my ASP.NET web application, I have defined custom error pages in my web.config file as follows:
<customErrors mode="On" defaultRedirect="~/default.html">
<error statusCode="404" redirect="~/PageNotFound.html" />
</customErrors>
In the case of a 404 error, my site redirects to the default.html page, but it passes “aspxerrorpath” as a query string parameter to the custom error page as follows:
http://www.example.com/default.html?aspxerrorpath=/somepathcausederror/badpage.aspx
I don’t want that behavior. I want the redirect URL to simply read:
http://www.example.com/default.html
Is there a way to achieve this?
My first thought would be to create a HttpHandler which catches url’s with
aspxerrorpathin it, and strips it. You could probably do the same with the rewrite module in IIS7 as well.