我将一个ASP.NET应用程序从IIS6迁移到IIS7,在这样做的同时我也将我的重写设置从Intelligencia.UrlRewriter移植到使用IIS重写。
在“Rejected-By-Urlscan”错误(像/åäö.html这样的/åäö.html应该被redirect到我的404页面)时遇到了一些问题。
在Intelligencia.UrlRewriter这工作:
<rewrite url="^~/Rejected-By-UrlScan" to="~/sidan-finns-inte.html"/>
我将其移植到:
<rule name="Rejected-By-UrlScan"> <match url="^Rejected-By-UrlScan" /> <action type="Rewrite" url="/sidan-finns-inte.html" /> </rule>
但我不断得到IIS内部404错误,而不是我的404错误(sidan-finns-inte.html)。
我怎样才能解决这个问题?
我解决了它通过添加:
<httpErrors errorMode="Custom"> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" path="/404.aspx" responseMode="ExecuteURL" /> <remove statusCode="500" subStatusCode="-1" /> <error statusCode="500" path="/Error.aspx" responseMode="ExecuteURL" /> </httpErrors>
在Web.Config中