3
我在ASP NET 4得到以下错误:有潜在危险的请求在asp.net 4
A potentially dangerous Request.Path value was detected from the client (<).
我已阅读,我需要在我的web.config使用requestValidationMode =“2.0”:
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime requestValidationMode="2.0" />
</system.web>
所以,我的方法是这样的:
[ValidateInput(false)]
public ActionResult Search(string query, string type){
//method body
return result;
}
它的伟大工程。但是,我无法修改我的Web.config文件,因为许多其他应用程序依赖于此文件,并且可能会在其他位置导致安全漏洞或错误。
我的应用程序足够安全,可以接受特殊字符,但我无法对正在开发的系统的其余部分说同样的话。 是否有替代方法接受特殊字符作为我的方法中的输入?
例子:
www.mydomain.com/search/query/<myquery<ffoo/type/dept
可能复制http://stackoverflow.com/questions/4361907/asp-net-mvc-3-validaterequestfalse-not-working-with-formcollection – Kath