如何prevent" aspxerrorpath"通过在asp.net错误页自定义错误页的查询字符串错误、自定义、字符串、QUOT

2023-09-03 11:55:32 作者:十里故清欢

在我的asp.net web应用程序我已经定义自定义错误页,我的web.config文件中,随后  <的customErrors模式=开的defaultRedirect =〜/ default.html>      <错误状态code =404重定向=〜/ PageNotFound.html/> < /的customErrors>

In my asp.net web application i have defined custom error pages in my web.config file as followed <customErrors mode="On" defaultRedirect="~/default.html"> <error statusCode="404" redirect="~/PageNotFound.html" /> </customErrors>

如果在我的网站页面的用户错误被重定向到default.html页,但它通过aspxerrorpath作为查询字符串参数自定义错误页如下

in case of error in my site page user is redirected to default.html page but it passes "aspxerrorpath" as query string parameter to the custom error page as following

http://www.mysite.com/default.html?aspxerrorpath=/somepathcausederror/badpage.aspx

页我不希望这样的行为我想重定向是简单地作为,   http://www.mysite.com/default.html

page i don't want that behavior i want the redirects to be simply as, http://www.mysite.com/default.html

有没有办法来实现这一目标?

is there a way to achieve this?

推荐答案

我的第一个想法是创建一个HttpHandler的惹人网址与 aspxerrorpath 在里面,去掉它。你也许可以在IIS7重写模块,以及这样做。

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.