Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
129 views
in Technique[技术] by (71.8m points)

c# - How to prevent "aspxerrorpath" being passed as a query string to ASP.NET custom error pages

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?

question from:https://stackoverflow.com/questions/4222226/how-to-prevent-aspxerrorpath-being-passed-as-a-query-string-to-asp-net-custom

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

My first thought would be to create a HttpHandler which catches url's with aspxerrorpath in it, and strips it. You could probably do the same with the rewrite module in IIS7 as well.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...