Deploying website: 500 - Internal server error

2018-12-31 03:36发布

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?

20条回答
骚的不知所云
2楼-- · 2018-12-31 03:56

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>
查看更多
深知你不懂我心
3楼-- · 2018-12-31 03:56

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.

查看更多
心情的温度
4楼-- · 2018-12-31 04:01

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>
查看更多
残风、尘缘若梦
5楼-- · 2018-12-31 04:01

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.

查看更多
查无此人
6楼-- · 2018-12-31 04:02

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.

查看更多
倾城一夜雪
7楼-- · 2018-12-31 04:02

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:

查看更多
登录 后发表回答