解决因为提交内容中带有 html 标记导致的报错
System.Web.HttpRequestValidationException: 从客户端(body="<font color='red'>te...")中检测到有潜在危险的 Request.Form 值。 在 System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection) 在 System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, RequestValidationSource requestCollection) 在 System.Web.HttpRequest.get_Form() 在 System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request) 在 System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() 在 System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
方法一:
修改Web.Config文件:
<configuration>
<system.web>
<pages validateRequest="false" />
</system.web>
</configuration>
方法二:
在.aspx页面中添加:
<%@ Page validateRequest="false" %>
方法三:
如果是.net 4.0 ,那么就增加以下内容即可
<system.web>
<httpRuntime requestValidationMode="2.0" />
</system.web>