简体   繁体   English

禁用特定页面的ValidateRequest

[英]Disable ValidateRequest for a specific page

Friends I am in trouble and need your help. 朋友,我很麻烦,需要您的帮助。

For database management in the admin section of my website I have few text fields where I would like to input data along with HTML tags. 对于我网站的admin部分中的数据库管理,我有几个文本字段,我想在其中输入数据以及HTML标签。 As soon as i add any HTML tag such as < BR /> the SQLDATASOURCE Update gives an error "A potentially dangerous Request.Form value was detected from the client" 一旦添加任何HTML标签(例如<BR />),SQLDATASOURCE Update就会给出错误消息“从客户端检测到潜在的Request.Form值”

Already tried ValidateRequest="false" but it didnt work Can not use AJAX Editor due to space issue. 已经尝试过ValidateRequest =“ false”,但由于空间问题而无法使用。无法使用AJAX编辑器。

<httpRuntime requestValidationMode="2.0" />

If i use httpRuntime requestValidationMode then it disable validation on the whole website making it open for hackers. 如果我使用httpRuntime requestValidationMode,那么它将在整个网站上禁用验证,使其对黑客开放。

Friends how can i disable ValidateRequest only for specific page(s) in the admin section only 朋友,我如何仅在管理部分中仅对特定页面禁用ValidateRequest

In .Net Framework 4.0, if you set requestValidationMode="2.0" in web.config, it doesn't means the whole site be will disabled for validation. 在.Net Framework 4.0中,如果在web.config中设置requestValidationMode =“ 2.0” ,则并不意味着整个站点都将被禁用以进行验证。 It just changed back to 2.0 validation mode which validate only for .aspx pages. 它只是改回了仅对.aspx页进行验证的2.0验证模式。 So you can apply validateRequest page driective attribute to false for the pages you want to disable after setting to 2.0 mode. 因此,对于要设置为2.0模式后要禁用的页面,可以将validateRequest页面驱动属性应用于false。

MSDN : requestValidationMode=2.0. MSDNrequestValidationMode = 2.0。 Request validation is enabled only for pages, not for all HTTP requests. 仅对页面启用请求验证,而不对所有HTTP请求都启用。 In addition, the request validation settings of the pages element (if any) in the configuration file or of the @ Page directive in an individual page are used to determine which page requests to validate . 另外,配置文件中pages元素(如果有)或单个页面中@ Page指令的请求验证设置用于确定要验证的页面请求

您可以在控制器方法或控制器上设置属性以禁用validationRequest

[ConfigurationPropertyAttribute("validateRequest", DefaultValue= false)]

您在页面指令中缺少ValidateRequest="false"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM