简体   繁体   English

在Umbraco的ASP.NET 4.5 RC中请求验证

[英]Request validation in ASP.NET 4.5 RC in Umbraco

I have a textbox in my ASP.NET 4.5 RC WebForms app which needs to accept potentially HTML. 我的ASP.NET 4.5 RC WebForms应用程序中有一个文本框,需要接受潜在的HTML。

I have researched this and have done the following to allow this to happen: In web.config I have set requestValidationMode and validateRequest appropriately. 我已经对此进行了研究,并做了以下操作来允许这种情况发生:在web.config中,我已经适当地设置了requestValidationMode和validateRequest。

<httpRuntime requestValidationMode="2.0" enableVersionHeader="false"/> 
<pages enableEventValidation="false" validateRequest="false">

On the control itself I have added the attribute ValidateRequestMode="Disabled" 在控件本身上,我添加了属性ValidateRequestMode =“ Disabled”

<asp:TextBox ID="txtBio" runat="server" TextMode="MultiLine" Height="100" Width="300" ValidateRequestMode="Disabled" />

However, still I get the error: 但是,仍然出现错误:

A potentially dangerous Request.Form value was detected from the client 从客户端检测到潜在的危险Request.Form值

Does anyone have any other ideas for what else I could try? 还有人对我可以尝试的其他方式有其他想法吗? I'm thinking it's a bug in the ASP.NET 4.5 RC web stack, but I'm probably wrong. 我认为这是ASP.NET 4.5 RC Web堆栈中的错误,但我可能错了。 It feels that way though as I'm literally out of ideas. 感觉就是这样,尽管我确实没有想法。 Seems like I have flicked every switch now. 似乎我现在已经轻拂了所有开关。

Plus, I would prefer to leave requestValidation on for everywhere except this item, however, if I can just turn it off at all, it would be a good start. 另外,我宁愿在除此项目之外的所有地方都保留requestValidation,但是,如果我可以完全将其关闭,那将是一个好的开始。

Many thanks 非常感谢

Try adding validateRequest="false" in the properties at the top of the page like this: 尝试在页面顶部的属性中添加validateRequest="false" ,如下所示:

%@ Page Language="C#" AutoEventWireup="true" CodeBehind="page.aspx.cs" validateRequest="false" Inherits="Project.UI.page" %>

But be careful to check html for any malicious scripts that users may add when validation is off. 但请务必检查html,以查看验证关闭后用户可能添加的任何恶意脚本。

UPDATE: Try adding this to your user control codebehind. 更新:尝试将此添加到后面的用户控件代码中。

protected void Page_Init(object sender, EventArgs e)
{
    try
    {
        ((umbraco.UmbracoDefault)this.Page).ValidateRequest = false;
    }
    catch { }
} 

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

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