我有asp.net mvc应用程序,并且添加了一个自定义错误页面。当我添加普通的无效URL时,它可以工作,但是如果URL包含特殊字符(例如'>''<'),则无法通过安全测试。 无效的网址:http:// localhost / Error / a'a%5c'b%22c%3E%3f%3E%25%7d%7d%25%25%3Ec%3C [[%3f $%7b%7b% 25%7d%7dcake%5c?aspxerrorpath = / a
错误:从客户端(>)检测到一个潜在危险的Request.Path值。
说明:在执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。
我已经在webconfig和类似控制器中添加了自定义错误页面
<customErrors mode="On" defaultRedirect="~/Error/Index?error=1">
</customErrors>
ErrorController.cs
public ActionResult Index()
{
return View();
}
当我尝试使用特殊字符的无效URL时,控制器未执行
我在httpRuntime中尝试过 requestPathInvalidCharacters ,但随后它击中了ExceptionFilter,并抛出了类似“未找到视图'a'a'”的错误 网址:http:// localhost / Error / a'a%5c'b%22c%3E%3f%3E%25%7d%7d%25%25%3Ec%3C [[%3f $%7b%7b%25 %7d%7dcake%5c?aspxerrorpath = / a
<httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" />
我也尝试过
<httpErrors errorMode="Custom">
<remove statusCode="404" />
<error statusCode="404" path="/Error/404.htm"
responseMode="ExecuteURL" prefixLanguageFilePath="" />
<remove statusCode="500" />
<error statusCode="500" path="/Error/500.htm"
responseMode="ExecuteURL" prefixLanguageFilePath="" />
</httpErrors>
当我从网址中删除 aspxerrorpath 时,自定义错误页面正在工作