解决ASP.NET的“A potentially dangerous Request... value was detected”

最近做一个简单的web项目(.NET Framework 3.5),自定义了一个handler(类似Java内的Servlet),本地开发环境(VS2012)测试没有问题,发布到服务器的IIS就出错了,访问handler映射地址时出现如下提示:

A potentially dangerous Request.QueryString value was detected from the client 

搜查各种资料,大部分都是说在web.config中配置

<httpRuntime requestValidationMode="2.0" />
经MSDN官网查得,此项配置需要在.Net Framework 4.0以上才可使用,在VS中配置此项亦会遭到警告“不允许使用‘requestValidationMode’特性”。

原来requestValidationMode是在ASP.NET 4.0(即.Net Framework 4.0)以上才有效的,项目本来就是.Net 3.5的,所以根本不需要使用此特性。但是这个.Net 3.5的却在发布环境的IIS6上发布,IIS6默认使用ASP.NET 4.0所以就开启了对应的拦截功能。

解决方法只需要在IIS6中将项目的ASP.NET属性设置为2.0,然后在handler中加入validate="false"即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Key Features Learn how to design Single Page Applications (SPAs) with the latest versions of the popular frameworks Angular 2 and ASP.NET Web API An explicit focus on understanding how the two tools fit together gives this book a unique insight on how to make SPAs for you and your clients that just work This book covers all the major topics you need to create SPAs with ASP.NET Web API and Angular 2: routing, creating clean URLs, handling data (OData), and authentication Book Description For most developers, writing code is a balance between maintainability and productivity how quickly can you write it versus how much more you have to write in the future. Writing APIs goes some way to striking a balance, as you can have an API that feeds data from your back-end to front-end service for consumption. Now, this front-end can change to a mobile app, a website, desktop app, but what you do at the back doesn't change and remains ASP.NET Web API. This book focuses on blending and connecting ASP.NET Web API and AngularJS. We'll guide you through building a fully-featured, potentially shippable SPA project with all its core aspects in place: readable URIs, OData retrieval, authentication patterns, RESTful interfaces, and more. By the end of the book, you will be able to make impressive SPAs using ASP.NET Web API and Angular 2. This book focuses about blending/connecting together the two topic technologies: ASP.NET WebAPI and AngularJS. The book aims to be a guide to the readers throughout by building a fully-featured, potentially shippable SPA project with all its core aspects in place: readable URIs, OData retrieval, authentication patterns, RESTful interfaces and more. What you will learn Get to know the MVC 6 core aspects such as Model and Web API Controller Gain the required resources and configure the MVC 6 interface See how to client-route requests Set-up the data model using entity framework Extend the client controllers Secure your application against various security threats Table of Contents Chapter 1: Getting Ready Chapter 2: ASP.NET Controllers and Server-Side Routes Chapter 3: Angular 2 Components and Client-Side Routing Chapter 4: The Data Model Chapter 5: Persisting Changes Chapter 6: Applying Styles Chapter 7: Authentication and Authorization Chapter 8: Third-Party Authentication and External Providers Chapter 9: User Registration and Account Edit Chapter 10: Finalization and Deployment

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值