我在做WebServcies時,頁面調試,報類了下面這樣的錯誤信息:
System.Web.HttpRequestValidationException: 從客戶端(checkXML="<?xml version="1.0" ...")中檢測到有潛在危險的 Request.Form 值。 在 System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection) 在 System.Web.HttpRequest.<>c__DisplayClass5.<ValidateHttpValueCollection>b__3(String key, String value) 在 System.Web.HttpValueCollection.EnsureKeyValidated(String key) 在 System.Web.HttpValueCollection.Get(String name) 在 System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection) 在 System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request) 在 System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() 在 System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
百度后,獲得解決方案:
在Web.config配置文件中,向節點<httpRuntime> 里添加屬性 requestValidationMode="2.0",即可解決問題。(其實,requestValidationMode的值只要是4.0以下都可以。具體原因,百度搜索validateRequest="false" 設置無效 有帖子回答這個問題,這里就不說明原因了。)
參考:http://www.cnblogs.com/vingi/articles/2478134.html
