Deploying website: 500 - Internal server error
Asked Answered
P

23

230

I am trying to deploy an ASP.NET application. I have deployed the site to IIS, but when visiting it with the browser, it shows me this:

Server Error

500 - Internal server error.

There is a problem with the resource you are looking for, and it cannot be displayed.

After fiddling around with the web.config, I got:

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

How can I see the actual issue behind this server error?

Penury answered 22/3, 2011 at 1:22 Comment(1)
Make sure you have the wildcard mapping in place for MVC application on the directory...Jarib
A
345

First, you need to enable and see detailed errors of your web messages, because this is a general message without giving information on what's really happening for security reasons.

With the detailed error, you can locate the real issue here.

Also, if you can run the browser on the server, you get details on the error, because the server recognizes that you are local and shows it to you. Or if you can read the log of the server using the Event Viewer, you also see the details of your error.

###On IIS 6

<configuration>
    <system.web>
        <customErrors mode="Off"/>
        <compilation debug="true"/>
    </system.web>
</configuration>

###On IIS 7

<configuration>
    <system.webServer>
        <httpErrors errorMode="Detailed" />
        <asp scriptErrorSentToBrowser="true"/>
    </system.webServer>
    <system.web>
        <customErrors mode="Off"/>
        <compilation debug="true"/>
    </system.web>
</configuration>

Note: You can avoid the Debug=true. You only need to close the custom errors for a while and get the detailed error page.

This can help: How to enable the detailed error messages (from IIS).

Aversion answered 22/3, 2011 at 1:53 Comment(12)
Thanks for the post! The part that did it for me was: <httpErrors errorMode="Detailed" />Mortgagee
@codemonkeyliketab Must be the same... or similar... if you run iis express on your computer open your EventViewer...Aversion
run the browser on the server worked for me.. thank you brotherImposition
Is there any downside or security problem with enabling Detailed error option in IIS instead of 3rd option(detailed error for local request and custom error pages for remote request) as shown in this article : blogs.msdn.microsoft.com/rakkimk/2007/05/25/…Medicare
@Learning yes there is - you enable the detailed error only for short period of time to been able to find some of your errors and make your app running - then you close it backAversion
@Aversion Sir i am returning json response from my service(webapi) but in case of internal server error i am not getting that json response.I am getting internal server error with html page.So when i have enables Detailed error option from IIS now i am getting my json response and not html response handled by IIS.Medicare
@Learning Close it back - to have again the error - and check the servers logs where is crash.Aversion
@Aversion But the thing is i am successfully getting my json response in case of internal server in my local but i am not getting that my own json result in case of internal server error on IIS.I am having a method in which i get error :input string is not in correct format so i am returing this error along with 500 status code and this is working fine in local but on IIS i am not able to see this error(input string not in correct format) but only displaying error like :Internal server error and There is a problem with the resource you are looking for, and it cannot be displayedMedicare
Thanks, enabling detailed error messages from IIS helped.Shareeshareholder
<httpErrors errorMode="Detailed" /> this line worked for me, thanksTitre
If you have backup then replace web.config file from backup to new publish file. It will help you.Hoxie
Just add <httpErrors errorMode="Detailed" /> in <system.webServer>Biquadratic
A
26

I was pulling my hair out over this issue. Making sure the following entry was in the root web.config file fixed it for me:

<configuration>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>
</configuration>

Remember that you have to add this to the existing XML elements, if they're already there. You can't just add at the end of the file, because you can't have multiple copies of any element.

Adi answered 2/2, 2012 at 16:11 Comment(0)
S
12

For me, the following code in the web.config was the culprit. When I removed it, the web site worked fine.

  <staticContent>
    <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
  </staticContent>
Sandpaper answered 14/5, 2014 at 22:55 Comment(2)
Thanks ..worked for me but is that mimeMap required for displaying videos?Mycorrhiza
This "fix" is for a very specific issue, the OP was asking for a general answer that this does not coverDrosophila
I
11

I finally solved this "500 Internal server" error when deploying the ASP.NET MVC 3.0 application on godaddy.ocm shared hosting.

somehow there were discrepancies on the version of DLL files referenced and version mentioned in file web.config.

I tried all the options mentioned in various forum. Nothing helped, although everyone suggested the same kind of fix, but somehow it didn't work in my scenario. Finally after banging my head for two days. I decided to delete all DLL file reference and delete web.cofig (make a local copy) from the project and let the application throw the error and then add the DLL files one by one making copy to local=true.

After all the DLL files were added, I created a new ASP.NET MVC application and copied the web.config of new application to my actual application. So my actual application now has a new web.config, and then I copied the connectionstring and other references from the local copy of web.config that I saved.

I just compiled the application and published to a local folder and FTP the published folder to goDaddy.

It worked and finally my problem was solved.

Instantly answered 23/3, 2013 at 6:3 Comment(1)
My error solved by: #11360457 Also had to install ElmahUnhandled
P
10

In my case, I put a mistake in my web.config file. The application key somehow was put under the <appSettings> tag. But I wonder why it doesn't display a configuration error. The error 500 is too generic for investigating the problem.

Pd answered 6/4, 2012 at 18:18 Comment(1)
Just had the same here. web.config was copied by mistake to a sub directory and cause weired errord although I set the "show detailed errors" to true.Apul
A
8

My first attempt to publish and then run a very simple site serving only HTML produced "The page cannot be displayed because an internal server error has occurred."

The problem: I had the site set to .NET 3.5 in Visual Studio (right click web site project -> Property Pages -> Build), but had the Web Site in Azure configured as .NET 4.0. Oops! I changed it to 3.5 in Azure, and it worked.

Alexis answered 31/12, 2012 at 16:46 Comment(0)
H
7

Server Error 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. Goddady. Hosting - Web - Economy - Windows Plesk

In my case, I replace this code:

<configuration> 
  <system.webServer> 
    <httpErrors errorMode="Detailed" /> 
    <asp scriptErrorSentToBrowser="true"/> 
  </system.webServer> 
  <system.web> 
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.0"/>
  </system.web> 
</configuration>

Then change framework 3.5 to framework 4. It shows my detailed error. I delete code in:

<httpModules></httpModules>

It solved my problem.

Holmium answered 24/9, 2014 at 12:31 Comment(1)
I'd added <compilation debug="true" after reading the other tips, but on a separate rather than combined line to <compilation targetFramework=, thanks for helping me spot that.Technocracy
U
6

IIS also reports status code 500 without any event log hints if there are insufficient permissions on the physical home directory (i.e. IIS_IUSRS has no access).

Umont answered 3/7, 2014 at 13:20 Comment(0)
V
6

In addition to the other suggestions, make sure to change the existingResponse attribute of the httpErrors node to Auto from Replace, or to remove that property entirely.

<httpErrors existingResponse="Replace" />
                              ^^^^^^^ not going to work with this here
Veliz answered 13/8, 2014 at 1:50 Comment(0)
G
5

For IIS 10 There is a extra step to do other than changing the customErrors=Off to show the error content.

<system.web>
   <customErrors mode="Off" />
</system.web>
<system.webServer>
   <httpErrors existingResponse="PassThrough" errorMode="Detailed"/>
</system.webServer>

Raul answered the question in this link Turn off IIS8 custom errors by Raul

Guidry answered 9/5, 2017 at 19:19 Comment(2)
This solution was what was needed for IIS 10.0.14393.0.Volin
Worked for me, IIS 10, Windows Server 2016, ASP.NET MVC 5, .NET 4.7 - Tried everything else and nothing was working. Partial view error response with a status of 500 and custom errors returned from the server, but whilst it was working fine locally, it was was returning the above error on the live server. Adding the httpErrors node was the ticket. Nice one.Cerebrum
U
3

Probably your web.config file is wrong or is missing some tag. I solved my problem using the correct config tags for .NET 4.

<system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
        <assemblies>
            <add assembly="System.Deployment, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        </assemblies>
    </compilation>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
        <namespaces>
            <clear/>
            <add namespace="System"/>
            <add namespace="System.Collections"/>
            <add namespace="System.Collections.Specialized"/>
            <add namespace="System.Configuration"/>
            <add namespace="System.Text"/>
            <add namespace="System.Text.RegularExpressions"/>
            <add namespace="System.Web"/>
            <add namespace="System.Web.Caching"/>
            <add namespace="System.Web.SessionState"/>
            <add namespace="System.Web.Security"/>
            <add namespace="System.Web.Profile"/>
            <add namespace="System.Web.UI"/>
            <add namespace="System.Web.UI.WebControls"/>
            <add namespace="System.Web.UI.WebControls.WebParts"/>
            <add namespace="System.Web.UI.HtmlControls"/>
        </namespaces>
    </pages>
    <authentication mode="None"/>
</system.web>
Unwish answered 11/3, 2015 at 13:21 Comment(0)
D
3

I realized the permissions for the files and folders in your server also matter. I uploaded my files from a linux operating system and usually the permissions are limited for read and write. So when uploaded, the permission are still same as in the local machine.

I had the same error and i just changed the permissions for the folder i had uploaded and the error was gone.

Hope it helps someone.

Dordrecht answered 30/9, 2015 at 14:14 Comment(1)
Isn't this answer basically the same as this answer from July 2014?Sporocarp
C
2

500 Internal Error
Windows Hosting Error

Godaddy Hosting issue

I have been facing the same issue, but now my issue has been resolved. Always use in this hosting this it works.

I will also recommend you all to do whatever changes you are looking to make in your web.config file. Please do it one by one and test the same on the live domain so that you can find the exact problem or the features that your hosting provider does not allow you to use.

<?xml version="1.0"?>

<configuration>
    <system.web>
        <trust level="Medium"/>
        <compilation debug="true" targetFramework="4.5">
            <assemblies>
                <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            </assemblies>
        </compilation>

        <httpRuntime targetFramework="4.5" />
        <sessionState mode="InProc" cookieless="false" timeout="90" />
        <authentication mode="Forms">
            <forms loginUrl="default.aspx"  
                   defaultUrl="default.aspx"
                   protection="All"
                   cookieless="UseCookies"
                   slidingExpiration="false"
                   timeout="30"
                   name="aeon.corpusjuris.in" />
        </authentication>

        <customErrors 
            mode="Off" 
            defaultRedirect="errorpage.aspx">

            <error statusCode="403" redirect="errorpage.aspx"/>
            <error statusCode="404" redirect="errorpage.aspx"/>
        </customErrors>

        <!--  <httpModules>
                <add name="HTTPCaching" type="HTTPCaching"/>
            </httpModules>
        -->
    </system.web>

    <runtime>
        <performanceScenario value="HighDensityWebHosting"  />
    </runtime>

    <system.webServer>
        <!--  <modules runAllManagedModulesForAllRequests="true">
                <add name="HTTPCaching" type="HTTPCaching"/>
            </modules>
        -->

        <defaultDocument>
            <files>
                <clear />
                <add value="default.aspx" />
            </files>
        </defaultDocument>

        <httpErrors errorMode="Detailed" />
        <asp scriptErrorSentToBrowser="true"/>

        <staticContent>
            <clientCache cacheControlCustom="public"
                         cacheControlMaxAge="60:00:00"
                         cacheControlMode="UseMaxAge" />
        </staticContent>
    </system.webServer>

    <system.web.extensions>
         <scripting>
             <webServices>
                 <jsonSerialization maxJsonLength="90000000">
                 </jsonSerialization>
             </webServices>
         </scripting>
    </system.web.extensions>

</configuration>
Crystallography answered 22/3, 2011 at 1:22 Comment(1)
in my case the error was caused by <httpRuntime enableVersionHeader="false" /> in web.configEndorsed
J
2

500 internal server error can arise due to several reasons. First reason might be that web.config file is not properly created, means you have missed some tag in the web.config file. Secondly this error can be due to some code problem. To check which component of the web application is causing this error you can check Application setting in web.config file. The detail of solving and tracing 500 internal server error with diagram is given here:

Jackscrew answered 6/9, 2014 at 1:22 Comment(0)
T
2

If you're using a custom HttpHandler (i.e., implementing IHttpModule), make sure you're inspecting calls to its Error method.

You could have your handler throw the actual HttpExceptions (which have a useful Message property) during local debugging like this:

    public void Error(object sender, EventArgs e)
    {
        if (!HttpContext.Current.Request.IsLocal)
            return;
        var ex = ((HttpApplication)sender).Server.GetLastError();
        if (ex.GetType() == typeof(HttpException))
            throw ex;
    }

Also make sure to inspect the Exception's InnerException.

These answered 9/11, 2016 at 10:15 Comment(0)
E
1

Make sure your account uses IIS 7. For more information, see Customizing IIS Settings on Your Windows Hosting Account. Follow the instructions in Changing Pipeline Mode on Your Windows IIS 7 Hosting Account. Select Integrated Pipeline Mode. In your Project References section, set Copy Local to True for the following assemblies:

System.Web.Abstractions
System.Web.Helpers
System.Web.Routing
System.Web.Mvc
System.Web.WebPages

Add the following assemblies to your project, and then set Copy Local to True:

Microsoft.Web.Infrastructure
System.Web.Razor
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
Publish your application.
Effeminate answered 25/10, 2014 at 16:28 Comment(0)
C
1

Sometimes, the reason might be one of your .dll assemblies is not registered correctly on the server.

For example, you can successfully run a C# Excel web application on your local machine with Office installed, while getting the 500 error on server deployment, because there is no Office suite installed on the server, and thus you get the server error.

Coagulant answered 16/3, 2015 at 20:3 Comment(0)
W
1

Before changing the web.config file, I would check that the .NET Framework version that you are using is exactly (I mean it, 4.5 != 4.5.2) the same compared to your GoDaddy settings (ASP.Net settings in your Plesk panel). That should automatically change your web.config file to the correct framework.

Also notice that for now (January '16), GoDaddy works with ASP.Net 3.5 and 4.5.2. To use 4.5.2 with Visual Studio it has to be 2012 or newer, and if not 2015, you must download and install the .NET Framework 4.5.2 Developer Package.

If still not working, then yes, your next step should be enabling detailed error reporting so you can debug it.

Witwatersrand answered 20/1, 2016 at 16:20 Comment(0)
G
1

For those who have this possibility (VPS hosting not web hosting):

Connect to your hosting server via Remote Desktop. Open Web Browser from your remote desktop and you will see the detail description of the error.

You don't need to modify web.config or expose any details to anybody else.

Gainor answered 28/10, 2016 at 7:59 Comment(0)
A
1

If you are using IIS 8.5 it may be that you need to change the ApplicationPool ID setting from ApplicationPoolId to NetworkService

Right click the Application Pool in question, click on "Advanced Settings" and then scroll down to ID - it will probably be set to ApplicationPoolIdentity. Click the button (..) and select NetworkService from the dropdown list instead.

Also make sure that if it is a .NET 2.0 application that you are not referencing the 4.0 framework in your App Pool.

Airmail answered 1/2, 2017 at 11:51 Comment(0)
F
1

I recently got into same problem, the disk space was full on the server. Clearing some space has resolved the issue.

Forthright answered 27/9, 2019 at 5:36 Comment(0)
U
0

Faced same issue after I deployed rldc report related changes in my project. I was about to revert the changes. Then saw this thread...I concluded that Web.config is the source...I removed below section from the file...And it worked...

<system.web>
  <compilation debug="true" targetFramework="4.8">
    <buildProviders>
      <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
    </buildProviders>
    <assemblies>
      <add assembly="Microsoft.ReportViewer.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
      <add assembly="Microsoft.ReportViewer.DataVisualization, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
      <add assembly="Microsoft.ReportViewer.Design, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
      <add assembly="Microsoft.ReportViewer.ProcessingObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
      <add assembly="Microsoft.ReportViewer.WebDesign, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
      <add assembly="Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
    </assemblies>
  </compilation>
  <httpRuntime targetFramework="4.8" />
  <httpHandlers>
    <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" validate="false" />
  </httpHandlers>
</system.web>
Uvula answered 28/4 at 17:58 Comment(0)
R
-1

Try compiling in Debug mode (in Visual Studio). If you are in Release mode, a lot of URL Rewrite errors will not be available.

Image shows the Debug selection combobox in Visual Studio

enter image description here

Rifle answered 28/10, 2019 at 19:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.