IIS7不是一个坏的请求中返回HTTP 400 [英] IIS7 NOT returning HTTP 400 for a bad request

查看:664
本文介绍了IIS7不是一个坏的请求中返回HTTP 400的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我们上执行了大量的集成测试的MVC2网站。最显著,我们使用坏的URL时测试的行为。例如:

I have an MVC2 site that we perform a lot of integration tests on. Most significantly, we test the behaviour when using bad urls. For instance:

的http:// XXXX / V1 ?// Dy888 /1234567815分之1/ swlocation FV = 24安培; SV2 = 3及SV3 = 5

(注意两个斜杠V1后)。

(Note the two slashes after "v1".)

这应该产生一个HTTP 400错误的请求,并在开发环境(VS2008)一切工作按计划进行。但在测试环境IIS7或MVC2莫名其妙地看到通过这个和响应好像有只有一个斜线。这似乎是太聪明了,通过重写请求帮助我们。

This should yield a HTTP 400, Bad Request, and in the development environment (VS2008) everything works as planned. But on the test environment IIS7 or MVC2 somehow sees through this and responses as if there were only one slash. It seems to be too "smart", and helps us by rewriting the request.

我如何配置我的服务器不智能,并真正与正确的错误反应?

How can I configure my server to not be "smart", and to really respond with the correct error?

测试服务器的Windows Server 2008 IIS7。

The test server is Windows Server 2008 with IIS7.

谢谢!
- 尼克拉斯

Thanks! - Niklas

推荐答案

HTTP状态code 400定义如下:

The http status code 400 is defined as follows:

请求有语法错误或者是
  本来就不可能得到满足。

The request had bad syntax or was inherently impossible to be satisfied.

具有在URI一个额外的斜线(这是只有该请求作为一个整体的一部分)不能正确地被归类为所述请求的语法错误,并且也不会使得不可能满足请求,由于额外的正斜杠不会改变位置由URI指向。

Having an extra forward slash in the URI (which is only a part of the request as a whole) cannot rightly be classified as a syntax error of the request, and nor does it make it impossible to satisfy the request, since the extra forward slash does not change the location pointed to by the URI.

我觉得你的开发Web服务器是一个错误行为,并且为你的测试premise是错误的。

I think that your development web server is the one behaving wrongly and that the premise for your test is wrong.

这篇关于IIS7不是一个坏的请求中返回HTTP 400的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆