我正在使用jQuery调用一个ASP.NET页面,它充当我的ajax服务器页面,将我发送给它的数据保存在查询字符串中.在ASP.NET页当我try 读取查询字符串时,出现以下错误:
A potentially dangerous Request.QueryString value was detected from the client...
我已经在我的页面中设置了ValidateRequest="false"
.我不想为所有页面都设置它.因此,它是在页面级别而不是配置级别进行的:
var content = "<h3>Sample header</h3><p>sample para</p>"
content = encodeURIComponent(content);
var url = "../Lib/ajaxhandler.aspx?mode=savecontent&page=home<xt=" + content;
$.post(url, function (data) {
//check return value and do something
});
在我的ASP.NET页面中:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ajaxhandler.aspx.cs" ValidateRequest="false" Inherits="MyProject.Lib.ajaxhandler" %>
但是当我发送纯文本而不是html标记时,它工作得很好.