第三方控件FreeTextBox 出现的错误
<FTB:FreeTextBox ID="ftbExplain" runat="server" AllowHtmlMode="True" Height="300px"Language="zh-CN" Text="" Width="600px">
</FTB:FreeTextBox>
向里面添加英文字母或是汉字时有时好用有时报有检测到有潜在危险的 Request.Form 值。
有没有办法解决
--------------------编程问答-------------------- 在page标签加上 ValidateRequest="false" --------------------编程问答-------------------- 加上后需要注意安全问题,楼主百度一下吧 --------------------编程问答--------------------
在页面Page指令上加上ValidateRequest="false"
或者在web.config中system.web节点下pages节点中设置
<system.web>
<pages validaterequest="false"/>
</system.web> --------------------编程问答-------------------- 这些我已设置过
设置了两种
1在 web.congfig中的
<configuration>
<system.web>
<pages validateRequest="false" />
</system.web>
</configuration>
2在页面上设置
<%@ page validaterequest="false"/>
还有其他方法吗
--------------------编程问答-------------------- 除了
在 web.congfig中配置
<configuration>
<system.web>
<pages validateRequest="false" />
</system.web>
</configuration>
需不需要在web.config中配置
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<httpHandlers>
<add verb="GET" path="FtbWebResource.axd" type="FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox" />
</httpHandlers>
</system.web>
</configuration>
--------------------编程问答-------------------- 把HTML特殊符号过滤了。。
/// 去除HTML标记
public static string NoHTML(string strHtml)
{
strHtml= Regex.Replace(strHtml, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase);
strHtml= Regex.Replace(strHtml, @"<(.[^>]*)>", "", RegexOptions.IgnoreCase);
strHtml= Regex.Replace(strHtml, @"([\r\n])[\s]+", "", RegexOptions.IgnoreCase);
strHtml= Regex.Replace(strHtml, @"-->", "", RegexOptions.IgnoreCase);
strHtml= Regex.Replace(strHtml, @"<!--.*", "", RegexOptions.IgnoreCase);
strHtml= Regex.Replace(strHtml, @"&(quot|#34);", "\"", RegexOptions.IgnoreCase);
strHtml= Regex.Replace(strHtml, @"&(amp|#38);", "&", RegexOptions.IgnoreCase);
strHtml= Regex.Replace(strHtml, @"&(lt|#60);", "<", RegexOptions.IgnoreCase);
strHtml= Regex.Replace(strHtml, @"&(gt|#62);", ">", RegexOptions.IgnoreCase);
strHtml= Regex.Replace(strHtml, @"&(nbsp|#160);", " ", RegexOptions.IgnoreCase);
strHtml= Regex.Replace(strHtml, @"&(iexcl|#161);", "\xa1", RegexOptions.IgnoreCase);
strHtml= Regex.Replace(strHtml, @"&(cent|#162);", "\xa2", RegexOptions.IgnoreCase);
strHtml= Regex.Replace(strHtml, @"&(pound|#163);", "\xa3", RegexOptions.IgnoreCase);
strHtml= Regex.Replace(strHtml, @"&(copy|#169);", "\xa9", RegexOptions.IgnoreCase);
strHtml= Regex.Replace(strHtml, @"(\d+);", "", RegexOptions.IgnoreCase);
strHtml.Replace("<", "");
strHtml.Replace(">", "");
strHtml.Replace("\r\n", "");
strHtml= HttpContext.Current.Server.HtmlEncode(strHtml).Trim();
return strHtml;
}
补充:.NET技术 , ASP.NET