The page cannot be displayed because an internal server error has occurred on server
Asked Answered
B

10

65

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

Burned answered 9/6, 2015 at 11:45 Comment(0)
S
96

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" />
Sideman answered 13/2, 2016 at 0:12 Comment(5)
It also applies to types such as .woff.Cordellcorder
I was sure this one didn't apply to me, but I removed everything in staticContent and I can finally see the real error message! Thanks.Gossip
Clearing the entry before setting it should prevent clashes <remove fileExtension=".json" /> <mimeMap fileExtension=".json" mimeType="application/json" />Dialogist
This is exactly the issue i had... Removing as above did the trick, thanks!Support
same here, the MIME types in the web.config file for MVC app were already defined in the server IIS applicationConfig file, so once removed from the web.config file at the site level, statis files were served.Eatable
K
50

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". "

Kovrov answered 11/6, 2017 at 16:44 Comment(4)
this helped me identify the issueArchean
this helped me identify Simon's issue tooLeviticus
This helped me too, I had duplicated subsection in <rewrite> configuration. Two sections had same names...Pasty
Thanks alot, this is actually the best answer!Roguish
C
8

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.

Concuss answered 9/6, 2015 at 12:10 Comment(1)
In my case, I was migrating a web site from II7 to an IIS8.x Win 2012 Server, and it seems the format for httpErrors may be slightly different between the two servers. Commenting out the httpErrors section fixed the issue for me. I recreated the custom errors from the IIS8.5 GUI after deleting the httpErrors section from the web.config that came from the IIS7.x server.Rybinsk
B
5

I've fixed it. I had the following section in web.config :

httpErrors existingResponse="PassThrough"

When I remove it, I got a real error

Burned answered 9/6, 2015 at 12:35 Comment(0)
W
3

In my case, setting httpErrors and the like in Web.config did not help to identify the issue.

Instead I did:

  1. Activate "Failed Request Tracing" for the website with the error.
  2. Configured a trace for HTTP errors 350-999 (just in case), although I suspected 500.
  3. Called the erroneous URL again.
  4. Watched in the log folder ("%SystemDrive%\inetpub\logs\FailedReqLogFiles" in my case).
  5. 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.

Woodcock answered 12/8, 2018 at 21:40 Comment(0)
A
1

it seems it works after I commented this line in web.config

<compilation debug="true" targetFramework="4.5.2" />
Alsatian answered 23/1, 2018 at 14:59 Comment(1)
In this case, I believe you could simply install that framework version (or maybe a higher one) from Windows "Programs and Features", under the IIS section.Forensic
D
1

I ended up on this page running Web Apps on Azure.

The page cannot be displayed because an internal server error has occurred.

We ran into this problem because we applicationInitialization in the web.config

<applicationInitialization
    doAppInitAfterRestart="true"
    skipManagedModules="true">
    <add initializationPage="/default.aspx" hostName="myhost"/>
</applicationInitialization>

If running on Azure, have a look at site slots. You should warm up the pages on a staging slot before swapping it to the production slot.

Dictaphone answered 25/9, 2018 at 9:27 Comment(0)
N
1

I got the same error when I added the applicationinitialization module with lots of initializationpages and deployed it on Azure app. The issue turned out to be duplicate entries in my applicationinitialization module. I din't see any errors in the logs so it was hard to troubleshoot. Below is an example of the error code:

  <configuration>
  <system.webServer>
    <applicationInitialization doAppInitAfterRestart="true" skipManagedModules="true">
      <add initializationPage="/init1.aspx?call=2"/>
      <add initializationPage="/init1.aspx?call=2" />
    </applicationInitialization>
  </system.webServer>

Make sure there are no duplicate entries because those will be treated as duplicate keys which are not allowed and will result in "Cannot add duplicate collection entry" error for web.config.

Nyberg answered 16/1, 2020 at 16:41 Comment(0)
R
1

I was hosting with Everleap and migrated to Azure, where I was getting this error. Everleap deployments to their servers required the following in the web.config `<system.webServer> section:

<modules>
    <remove name="AspNetCoreModuleV2" />
    <add name="AspNetCoreModuleV2" />
  </modules>

When I commented out this code, the app worked on Azure.

Rupee answered 21/4, 2021 at 19:16 Comment(0)
P
0

For those of you who hit this stackoverflow entry because it ranks high for the phrase:

The page cannot be displayed because an internal server error has occurred.

In my personal situation with this exact error message, I had turned on python 2.7 thinking I could use some python with my .NET API. I then had that exact error message when I attempted to deploy a vanilla version of the API or MVC from visual studio pro 2013. I was deploying to an azure cloud webapp.

Hope this helps anyone with my same experience. I didn't even think to turn off python until I found this suggestion.

Polyzoan answered 31/3, 2016 at 0:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.