因此,我试图提交一个字符串作为参数在Js中发布到asp.net服务,而我有一些困难。在声明之前,我无法访问服务器,也无法触及验证,我严格从外部客户端访问。我得到这个响应返回从客户端检测到有潜在危险的Request.Form值,请编码帮助
System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (message="...t;img src='http://192.168.1...").
at System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)
at System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, RequestValidationSource requestCollection)
at System.Web.HttpRequest.get_Form()
at System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request)
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
我发送的信息是:
xcvxzcvzxcvxcvzxcv< br /><img src='http://192.168.1.1:82/UserUploads/Images/65968/20130122020024996.jpg' alt='User Image' />
其中我用编码:
htmlEncode: function(str) {
str = str.replace(/&/g, '&');
str = str.replace(/'/g, ''');
str = str.replace(/"/g, """);
str = str.replace(/</g, '<');
str = str.replace(/>/g, '>');
return str;
},
主要生产:
xcvxzcvzxcvxcvzxcv< br /><img src='http://192.168.1.1:82/UserUploads/Images/65968/20130122020802027.jpg' alt='User Image' />
我已经通过了几个验证器并检查了我的en编码,我无法弄清楚是什么导致了这个问题。我唯一的猜测是,http://导致问题,因为它显示在JavaScript错误,但我不知道。任何帮助或见解将不胜感激。
可以显示实际执行POST的代码吗? – PleaseStand
这是'实体。看起来像任何..;编码在asp.net中被标记为危险。 – Ceres
宾果,就是这样,换出'转换',它完美的作品 – knightsbore