我正在使用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&ltxt=" + 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标记时,它工作得很好.

推荐答案

如果这是ASP.NET4,则breaking change等于ValidateRequest.有关requestValidationMode的详细信息,请参阅this StackOverflow question.

Asp.net相关问答推荐

将 Response.Headers.Add 替换为方法属性decorator

如何在 asp.net 服务器中使用字体

目前不支持超过 65534 个段的跨区存档

在正则表达式中允许 -(破折号)

跨子域共享 ASP.NET cookie

没有身份的 ASP.NET Core 2.0 承载身份验证

如何从 web.config 中读取系统值并在 ASP.NET MVC C# 方法中使用

stream.CopyTo - 文件为空.网

在 Asp.net mvc5 中使用用户名而不是邮箱作为身份

防止在 Visual Studio 2008 ASP.NET Web 窗体中复制粘贴时自动生成 ID

判断邮箱地址是否对 System.Net.Mail.MailAddress 有效

如何将枚举类型绑定到 DropDownList?

获取页面上特定类型的所有 Web 控件

在 ASP.NET 中使用 Messenger Connect 客户端库时出现 Javascript 错误

Owin 中是否有来自 Global.asax 的 Application_End?

如何在 ASP.Net 网络表单中使用标签?

在 aspnetcore (netcoreapp1.0) 中替代 System.Web.Security.Membership.GeneratePassword

导航到本地 IIS Express 时,Chrome 会返回错误请求 - 请求太长

将字典绑定到中继器

x-powered by是什么意思?