asp.netazureopenrasta

How to configure error response formatting on Windows Azure Web App


I am building a demo API for some sort of issue tracker using Open Rasta and ASP.NET - and deploying to a Windows Azure Web App.

The API returns detailed error information in a dedicated media-type (application/mason+json). On my local machine I get the expected error response, but on Azure I only get the error code (for instance 404) and a standard ASP.NET error message.

See for instance http://mason-issue-tracker.azurewebsites.net/projects/999 which should have returned application/mason+json but returns HTML instead.

Is there a setting somewhere in Azure to change this?


Solution

  • The missing setting in web.config was this:

    <system.webServer>
       <httpErrors existingResponse="PassThrough"></httpErrors>
    </system.webServer>
    

    That fixed it for me. I still do not know why it is required on Azure but not on my local machine(s).

    Found the answer at http://develoq.net/2011/returning-a-body-content-with-400-http-status-code/. The setting is documented at https://msdn.microsoft.com/en-us/library/ms690497%28VS.90%29.aspx