The page cannot be displayed because an internal server error has occurred on server
I've installed website on my local machine using IIS 7 successfully. But when I've deployed it on live server, I got the following error:
"The page cannot be displayed because an internal server error has occurred" Nothing else.
Using the same IIS 7 on live and also set to have Detailed errors
in Error Pages module, but still getting the same.
What can be a reason?
Thanks
I just got this error and it was caused by a duplicate static content MIME type in the web.config
This error was being returned only on static files - eg images, css, js files were all saying this error (text by itself, no other html or text in the response).
The way to debug this is to look in web config under static content. Here we have a json file extension loaded. This was required on IIS7 but will kill the app if used on IIS8 because json is now pre-loaded at the server level.
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
So solution is to remove any of these mimeType entries one at a time to confirm which are needed and which kill your app!
Update
Actually the best solution was provided by a commenter here. You can remove and then add, which will always work regardless of whether it is already defined or not. Like this:
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
I think the best first approach is to make sure to turn on detailed error messages via your web.config file, like this:
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed"></httpErrors>
</system.webServer>
</configuration>
After doing this, you should get a more detailed error message from the server.
In my particular case, the more detailed error pointed out that my <defaultDocument>
section of the web.config file was not allowed at the folder level where I'd placed my web.config. It said
This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false". "
Modify your web.config to display the server error details:
<system.web>
<customErrors mode="Off" />
</system.web>
You may also need to remove/comment out the follow httpErrors section
<system.webServer>
<httpErrors errorMode="Custom">
<remove statusCode="404" />
<error statusCode="404" path="/Error/Error404" responseMode="ExecuteURL" />
<remove statusCode="500" />
<error statusCode="500" path="/Error/Error500" responseMode="ExecuteURL" />
<remove statusCode="403" />
<error statusCode="403" path="/Error/Error403" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
From my experience if you directly have a server error, this may be caused from an assembly version mismatch.
Check what is declared in the web.config and the actual ddl in the bin folder's project.
I've fixed it.
I had the following section in web.config
:
httpErrors existingResponse="PassThrough"
When I remove it, I got a real error
In my case, setting httpErrors
and the like in Web.config did not help to identify the issue.
Instead I did:
- Activate "Failed Request Tracing" for the website with the error.
- Configured a trace for HTTP errors 350-999 (just in case), although I suspected 500.
- Called the erroneous URL again.
- Watched in the log folder ("%SystemDrive%\inetpub\logs\FailedReqLogFiles" in my case).
- Opened one of the XML files in Internet Explorer.
I then saw an entry with a detailed exception information. In my case it was
\?\C:\Websites\example.com\www\web.config ( 592) :Cannot add duplicate collection entry of type 'mimeMap' with unique key attribute 'fileExtension' set to '.json'
I now was able to resolve it and fix the error. After that I deactivated "Failed Request Tracing" again.