在普通的asp.net下,可以通过在页面上注明 validateRequest=“false" 这个选项来关闭请求对注入攻击的验证,但在mvc下则不行。而且,在asp.net 4.0下,哪怕是在 action 上注明 [validateInput(false)] 也无法让验证关闭。对此微软的解释是:

ASP.NET Request Validation

The
request validation feature in ASP.NET provides a certain level of
default protection against cross-site scripting (XSS) attacks. In
previous versions of ASP.NET, request validation was enabled by default.
However, it applied only to ASP.NET pages (.aspx files and their class
files) and only when those pages were executing.

In ASP.NET 4, by default, request validation is enabled for all requests, because it is enabled before the BeginRequest
phase of an HTTP request. As a result, request validation applies to
requests for all ASP.NET resources, not just .aspx page requests. This
includes requests such as Web service calls and custom HTTP handlers.
Request validation is also active when custom HTTP modules are reading
the contents of an HTTP request.

As a result, request validation
errors might now occur for requests that previously did not trigger
errors. To revert to the behavior of the ASP.NET 2.0 request validation
feature, add the following setting in the Web.config file:

<httpRuntime requestValidationMode="2.0" />

However,
we recommend that you analyze any request validation errors to
determine whether existing handlers, modules, or other custom code
accesses potentially unsafe HTTP inputs that could be XSS attack
vectors.

ASP.NET 4 Breaking Changes

Asp.net mvc validaterequest无效的问题的更多相关文章

  1. ASP.NET MVC Application_Error 无效不执行

    我们一般在开发 ASP.NET MVC 应用程序的时候,会在 Application_Error 中添加异常日志记录,一般会记录 500 的错误信息,但如果应用程序在出错的时候,Application ...

  2. 【记录】ASP.NET MVC 4/5 Authentication 身份验证无效

    在 ASP.NET MVC 4/5 应用程序发布的时候,遇到一个问题,在本应用程序中进行身份验证是可以,但不能和其他"二级域名"共享,在其他应用程序身份验证,不能和本应用程序共享, ...

  3. 关于linux asp.net MVC网站中 httpHandlers配置无效的处理方法

    近期有Jexus用户反映,在Linux ASP.NET MVC网站的Web.config中添加 httpHandlers 配置用于处理自定义类型,但是在运行中并没有产生预期的效果,服务器返回了404( ...

  4. Asp.net mvc 自定义全局的错误事件HandleErrorAttribute无效

    Asp.net mvc 自定义全局的错误事件HandleErrorAttribute,结果无效, 原因: 1.没有在RegisterGlobalFilters 里面添加或者你要的位置添加. 2.你把这 ...

  5. 解决ASP.NET MVC AllowAnonymous属性无效导致无法匿名访问控制器的问题

    在ASP.NET MVC项目中,一般都要使用身份验证和权限控制,但总有部分网页是可以匿名访问的.使用AllowAnonymous属性就可以指定需要匿名访问的控制器,从而跳过身份验证. 但是今天却遇到一 ...

  6. Asp.Net MVC 页面代码压缩筛选器-自定义删除无效内容

    Asp.Net MVC 页面代码压缩筛选器 首先定义以下筛选器,用于代码压缩. /*页面压缩 筛选器*/ public class WhiteSpaceFilter : Stream { privat ...

  7. asp.net mvc 中[Authorize]在IE9以上版本关于FormsAuthentication.SetAuthCookie无效的问题 解决方案

    简单的解决方法是,在网站根目录,新增一个浏览器定义文件(browser definition file) 叫“App_Browsers”文件夹,然后里面放一个“IE10.browser”文件即可,网站 ...

  8. ASP.NET MVC中MaxLength特性设置无效

    在ASP.NET MVC项目中,给某个Model打上了MaxLength特性如下: public class SomeClass { [MaxLength(16, ErrorMessage = &qu ...

  9. 成员资格、授权 – ASP.NET MVC 4 系列

           ASP.NET MVC 不像 ASP.NET WEB FORMS 那样提供了很多自动保护机制来保护页面不受恶意用户的攻击,更明确的说,后者是致力于使应用程序免受攻击: 服务器组件对显示的 ...

随机推荐

  1. Django部署时为什么要用 uWSGI与 Nginx? 以及 WSGI,uwsgi等协议

    Django框架的服务器架构一般是 Nginx + uWSGI + Django (1)一些基本概念 1 WSGI协议,uwsgi协议 WSGI协议(通讯协议):Python用于Web开发的协议(用于 ...

  2. 4. 什么是应用服务器? - JavaEE基础系列

    本文是JavaEE基础系列的第四节. Java EE简介 - JavaEE基础系列 JSR简介 - JavaEE基础系列 什么是JSR参考实现? - JavaEE基础系列 上一节介绍了什么是JSR参考 ...

  3. C# 超级狗 二次开发 读写数据 激活验证 存储数据库连接字符串

    本文主要讲解如果使用C#语言来对超级狗进行二次开发,如果仅仅是做个激活的功能,可以参照另一篇博客,地址:http://www.cnblogs.com/dathlin/p/8487842.html 如果 ...

  4. IOS开发 ARC和非ARC下使用Block属性的问题

    1. Block的声明和线程安全 Block属性的声明,首先需要用copy修饰符,因为只有copy后的Block才会在堆中,栈中的Block的生命周期是和栈绑定的,可以参考之前的文章(iOS: 非AR ...

  5. key相同合并Map

    public class Demo11 { public static void main(String[] args) { ConcurrentHashMap<Integer, Map< ...

  6. caffe 细节

    batch :http://www.zhihu.com/question/32673260 caffe blog: http://blog.csdn.net/abcjennifer/article/d ...

  7. Learning Scrapy(一)

    学习爬虫有一段时间了,从Python的Urllib.Urlllib2到scrapy,当然,scrapy的性能且效率是最高的,自己之前也看过一些资料,在此学习总结下. Scrapy介绍 关于scrapy ...

  8. xgboost系列之应用xgboost的注意事项

    问题:win和mac平台运行相同的xgboost代码,效果不同? 解决:xgboost的参数colsample_bytree设置为1.

  9. Jmter-Test Fragment、Include Controller和Module Controller

    Test Fragment--测试片段 The Test Fragment is used in conjunction with the Include Controller and Module ...

  10. 《DSP using MATLAB》示例Example7.10

    代码: ws1 = 0.2*pi; wp1 = 0.35*pi; wp2 = 0.65*pi; ws2 = 0.8*pi; As = 60; tr_width = min((wp1-ws1), (ws ...