Reputation: 337
I have a controller with a method which should only output static JSON content to the browser. E.g.
public async Task<ActionResult> Test()
{
return Content("{ \"key\": \"value\" }", "application/json");
}
This works fine when I debug locally via Visual Studio, however, after deployed on IIS the response is just blank.
So feels like some configuration on the IIS that needs to be done?
Does anyone have any idea?
Upvotes: 0
Views: 76
Reputation: 337
I managed to solve this by adding the following to <system.webServer> tag in Web.config;
<httpErrors errorMode="DetailedLocalOnly" existingResponse="PassThrough">
</httpErrors>
Upvotes: 1
Reputation: 23
Did you try using JsonResult instead?
public async Task<JsonResult> Test()
{
return new JsonResult()
{
Data = new { key = "value" },
JsonRequestBehavior = JsonRequestBehavior.AllowGet
};
}
Upvotes: 1