Dav*_*vid 4 asp.net security error-handling asp.net-mvc
在我自己的网站上做一些黑客攻击时,我遇到(在谷歌搜索后)一个常见的问题.
"从客户端检测到一个潜在危险的Request.Form值,可能是XSS尝试或恶意角色
情况1 : A potentially dangerous Request.Form value was detected from the client (Firstname ="<script> alert("x");...").
案例2:A potentially dangerous Request.Form value was detected from the client (*)."
asp mvc团队为我捕获错误做得很好但是如何向用户显示更好的错误.例如"发生了一些事情,请重复您的步骤,如果再次出现此消息,请联系x ...".
asp MVC开发人员的解决方案.
<customErrors mode="On" defaultRedirect="~/Error/Index"/>
可选你可能想把mode ="RemoteOnly"
有关CustomErrors属性的更多信息,请注意:customErrors元素
它不是MVC特有的.ASP.Net webforms会给你同样的错误.
我认为你应该使用自定义错误页面.自定义错误页面在Web.config中定义,如:
<customErrors mode="RemoteOnly" defaultRedirect="~/Error.aspx"/>
Run Code Online (Sandbox Code Playgroud)
有关自定义错误页面的更多信息,请访问http://aspnetresources.com/articles/CustomErrorPages
此外,您可以处理Global.asax Application_Error事件以执行任何操作.
微软有一篇非常好的文章,包括源代码,它完全符合您的要求(以及更多).请访问http://support.microsoft.com/kb/306355查看
| 归档时间: |
|
| 查看次数: |
4003 次 |
| 最近记录: |