可以设置RequestValidationMode ="2.0"页面级别吗?

Can Set RequestValidationMode=“2.0” page level?
2021-09-15
  •  译文(汉语)
  •  原文(英语)

我正在开发基于ASP.NET 4.0的Web应用程序,并且有一些页面具有潜在的危险请求(具有标记代码).

因此,除了在web.config中设置RequestValidationMode ="2.0"之外,我还可以仅为那几个页面设置该属性吗?

解决过程1

答案隐藏在msdn中的某个地方,希望对您有所帮助.

<location path="test.aspx">
<system.web>
<httpRuntime requestValidationMode="2.0" />
</system.web>
</location>

参考

http://msdn.microsoft.com/zh-CN/library/hh882339(v=vs.100).aspx

解决过程2

为避免此错误:从客户端检测到潜在危险的request.form值.

您可以使用页面级属性: <%@ Page ... ValidateRequest="false" %>

速聊1:
Yer.Already在页面中使用此指令ValidateRequest ="false".但它似乎不适用于.Net4.0应用程序.因此建议在web.config中使用<httpRuntime requestValidationMode ="2.0" />.然后工作正常.但是,设置此属性后,它不仅适用于该页面,而且适用于所有HTTP请求.
速聊2:
您是否已通过此链接出现了类似的问题:stackoverflow.com/questions/2673850/…
速聊3:
我浏览了该链接,还提到在web.config文件中使用<httpRuntime requestValidationMode ="2.0" />.实际上,我正在寻找一种仅针对几个页面(运行时代码隐藏或页面级)添加此属性的方法.不适用于所有HTTP请求.如有可能,请更新.谢谢.

I am developing a web application based on ASP.NET 4.0 and having some few pages with potential dangerous request(having markup codes).

So instead of setting RequestValidationMode="2.0" in web.config, can I set that property only for those few pages?

Solutions1

Answer hidden somewhere in msdn, hope this helps you too.. Better late then never Try this,

<location path="test.aspx">
<system.web>
<httpRuntime requestValidationMode="2.0" />
</system.web>
</location>

Reference

http://msdn.microsoft.com/en-us/library/hh882339(v=vs.100).aspx

Solutions2

for avoiding this error: potentially dangerous request.form value was detected from the client.

you can use page level property : <%@ Page ... ValidateRequest="false" %>

Talk1:
Yer.Already Used this directive ValidateRequest="false" in page. But it seems not working for .Net4.0 applications. So the suggestion was use <httpRuntime requestValidationMode="2.0" /> in web.config. And then it works fine. But when set this property it applies not only that page but for all HTTP requests.
Talk2:
have you gone through this link there similar issue is raised: stackoverflow.com/questions/2673850/…
Talk3:
I went through that link and it is also mentioned use <httpRuntime requestValidationMode="2.0" /> in web.config file. Actually I am looking for a way to add this property only for few pages(Either run-time code-behind or page-level). not for all HTTP requests. If any possibilities please update. Thanks.
转载于:https://stackoverflow.com/questions/15544555/can-set-requestvalidationmode-2-0-page-level

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入