How to Get Error Details of an ASP.NET 5 app deployed on Azure Websites?

后端 未结 10 1851
执笔经年
执笔经年 2020-12-05 02:23

I have an ASP.NET 5 solution with a website and several project libraries. I\'m using MVC 6 and Entity Framework 7. Locally the app is working fine and until today it was wo

相关标签:
10条回答
  • 2020-12-05 02:27

    You must set app settings property ASPNET_DETAILED_ERRORS to true in web.config file.

    Example of my edited web.config file:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <appSettings>
        <add key="bootstrapper-version" value="1.0.0-beta6" />
        <add key="runtime-path" value="..\approot\runtimes" />
        <add key="dnx-version" value="1.0.0-beta6" />
        <add key="dnx-clr" value="clr" />
        <add key="dnx-app-base" value="..\approot\src\MyApp" />
        <!-- This will turn on detailed errors when deployed to remote servers -->
        <!-- This setting is not recommended for production -->
        <add key="ASPNET_DETAILED_ERRORS" value="true" />
      </appSettings>
      <system.web>
        <httpRuntime targetFramework="4.5.1" />
      </system.web>
    </configuration>
    
    0 讨论(0)
  • 2020-12-05 02:34

    In RC1 (as of beta8, perhaps), one should apparently use:

    app.UseDeveloperExceptionPage();
    

    .. which apparently only works if app.Properties["host.AppMode"] is "development".

    But this didn't work for me. The error message I was getting was specifically "An error occurred while starting the application", I have found that none of the given configurations will resolve this because the error is occurring before the configurations execute.

    Somehow, the publish target folder must have gotten corrupted during publish because I found that deleting the entire deployment directory and re-publishing resolved the problem.

    Otherwise, here is the reference: http://docs.asp.net/en/latest/fundamentals/diagnostics.html https://docs.microsoft.com/en-us/aspnet/core/fundamentals/error-handling

    0 讨论(0)
  • 2020-12-05 02:34

    I've experienced the exact same error with a web app running dnx-clr-win-x64.1.0.0-rc1-update1. I did the deployment directly from Visual Studio 2015 Enterprise Update 1. I found that the site was working whenever I did the first deployment on a newly created web app. Starting with the second deployment (even when deploying the exact same content), I started to see Internal Server Error 500. That brought me to the following solution:

    Enabling "Remove additional files at destination" in the publishing wizard of Visual Studio fixed it for me.

    0 讨论(0)
  • 2020-12-05 02:36

    Create a web.config inside your wwwroot folder with this content :

    <configuration>
      <system.web>
        <customErrors mode="Off" />
      </system.web>
    </configuration>
    
    0 讨论(0)
  • 2020-12-05 02:36

    In my case with beta5, custom errors in web.config didn't help, local IIS was fine, and adding an exception handler didn't display anything. The only thing that worked was to nuke approot and redeploy.

    0 讨论(0)
  • 2020-12-05 02:38

    In the Web app's Application settings, in the section App settings, add (or change the value of) Hosting:Environment to Development. Then you get the same error page as in your local development. In my Startup.cs, I have the regular Configure() method with the following code: (still in MVC 1.0 RC1-final)

            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
    

    Hope this helps!

    0 讨论(0)
提交回复
热议问题