Jac*_*ker 24 asp.net-mvc azure
我的ASP.NET MVC控制器中有一个操作,当无效参数传递给操作时,返回带有400 Bad Request的JSON数据.
[HttpDelete]
public ActionResult RemoveObject(string id) {
    if(!Validate(id)) {
        Response.StatusCode = (int)HttpStatusCode.BadRequest;
        return Json(new { message = "Failed", description = "More details of failure" });
    }
}
这可以在IIS下运行,也可以在Visual Studio中启动开发测试服务器.将项目部署到Azure后,400 Bad Request将返回,而不会返回JSON数据.内容类型已更改为邮件的"text/html"和"Bad Request".
为什么Azure下的行为不同?
dcc*_*lie 53
将以下条目添加到"web.config".
<system.webServer>
  <httpErrors existingResponse="PassThrough"/>
</system.webServer>
这将允许HTTP错误通过非骚扰.
| 归档时间: | 
 | 
| 查看次数: | 5139 次 | 
| 最近记录: |