【发布时间】:2013-03-21 03:15:03
【问题描述】:
在我的 ASP.NET MVC 控制器中有一个动作,当无效参数传递给动作时,它返回带有 400 错误请求的 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”和“错误请求”。
为什么在 Azure 下的行为不同?
【问题讨论】:
标签: asp.net-mvc azure