Returning http status code 409 Conflict (without ASP.NET MVC alterations)

浪子不回头ぞ 提交于 2019-12-22 12:23:13

问题


I am trying to return a HTTP response with 409 status code, content type "application/json" and a json data in the content.

The problem is that at the client level, response.content returns html result. Somehow ASP.Net MVC has decided to return a html error message instead of what I intended. I've checked at web.config and 409 is not part of the custom error message. I've checked IIS 7.0 Error Pages section as well for 409 and it is not set there.

I wonder where I can find the default configuration that manage asp.net mvc http error code mechanism.

I am working based on ASP.Net MVC 2.0 and .Net 4.0 on Vista.


回答1:


Try doing Response.TrySkipIisCustomErrors = true; when sending the response back which will allow to skip the IIS Customer errors. You can read more about it in
http://www.west-wind.com/weblog/posts/2009/Apr/29/IIS-7-Error-Pages-taking-over-500-Errors



来源:https://stackoverflow.com/questions/4604696/returning-http-status-code-409-conflict-without-asp-net-mvc-alterations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!