开发者

IIS7 NOT returning HTTP 400 for a bad request

开发者 https://www.devze.com 2023-01-30 12:24 出处:网络
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:

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://x.x.x.x/v1//Dy888/1/1234567815/swlocation?fv=24&sv2=3&sv3=5

(Note the t开发者_如何学Pythonwo slashes after "v1".)

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?

The test server is Windows Server 2008 with IIS7.

Thanks! - Niklas


The http status code 400 is defined as follows:

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

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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消