iis-7 {"message":"an - WebApi's {“message”:“an error has occurred”} on IIS7, not in IIS Express

3 Answers

The problem was a missing dependency that wasn't on the server but was on my local machine. In our case, it was a Devart.Data.Linq dll.

To get to that answer, I turned on IIS tracing for 500 errors. That gave a little bit of information, but the really helpful thing was in the web.config setting the <system.web><customErrors mode="Off"/></system.web> This pointed to a missing dynamically-loaded dependency. After adding this dependency and telling it to be copied locally, the server started working.

occurred."} includeerrordetailpolicy

I'm working with ASP.NET MVC 4 WebApi and am having a lot of fun with it running it on my local computer on IIS Express. I've configured IIS Express to serve remote machines too, and so other's in my company are using my computer as our webserver.

After deciding this was a less-than-optimal solution, we decided to put the WebApi on a remote server after installing .NET 4.5. When I use fiddler and sent a POST to a controller on my local machine it returns the correct response, yet when I change the domain to the webserver running IIS7 the same POST returns a cryptic

{"message":"an error has occurred"}

message. Anyone have any idea what could be going on?

None of the other answers worked for me.

This did: (in Startup.cs)

public class Startup
    public void Configuration(IAppBuilder app)
        var config = new HttpConfiguration();


        // Here: 
        config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

(or you can put it in WebApiConfig.cs):

public static class WebApiConfig
    public static void Register(HttpConfiguration config)
        // Web API routes

            name: "DefaultApi",
            routeTemplate: "api/{controller}/{action}/{id}",
            defaults: new { id = RouteParameter.Optional }

        // Here: 
        config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

In case this helps anyone:

I had a similar issue, and following Nates instructions i added:

     <customErrors mode="Off"/>

this showed me more infomartion about the error:

"ExceptionMessage": "Unable to load the specified metadata resource.", "ExceptionType": "System.Data.Entity.Core.MetadataException", "StackTrace": " at System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(...

This is when I remembered that I had moved the edmx file to a different location and had forgot to change the connectionstrings node in the config (connectionsstrings node was placed in a seperate file using "configSource", but that's another story).