[英]Special characters causes an error in URL in ASP.NET
我在 URL 中輸入導致錯誤的特殊字符。 我想重定向一個特殊頁面,但我做不到。
404 重定向工作正常,但 400 重定向不能正常工作。
這些字符會導致 url 出現問題:
1- "%" - HTTP Error 400 - Bad Request-Invalid URL
2- "&" - HTTP Error 400
3- "<" - HTTP Error 400
4- ">" - HTTP Error 400
5- ":" - HTTP Error 400
我的Web.config設置:
<system.web>
<customErrors mode="On" redirectMode="ResponseRedirect" />
</system.web>
<system.webServer>
<httpErrors>
<remove statusCode="400" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="400" path="400.aspx" responseMode="Redirect" />
<error statusCode="404" path="404.aspx" responseMode="Redirect" />
</httpErrors>
</system.webServer>
As far as I know, the url Bad Request-Invalid URL is thrown by the http.sys not IIS or asp.net, so changing the custom error page is usless for this kind of issue.
此外,無法修改 http.sys 的自定義錯誤頁面。
如果您想讓 http.sys 允許 Invalid url,我建議您可以嘗試在以下注冊表項下創建以下 DWORD 值:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters
AllowRestrictedChars 1
更多細節,你可以參考這篇文章。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.