0
votes

I have a .NET core 2.0 web application running successfully as an Azure app service.

To save money/complication, I would like to run its public API on the same domain, as a virtual application i.e. www.mysite.com/api

However, when I release to the virtual application, and then try to access it, I simply get an error message saying:

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

I am an experienced .NET framework developer, but this is my first .NET core project, so I am a little unsure how to debug this.

Just to confirm, I have a .NET core website and a .NET core web API, where the web API is meant to live in the "/api" virtual application. I have setup the virtual application within the Azure app service as "site\api" (with the main website being "site\wwwroot")

The API has its own web.config etc. as expected. I am guessing this is all caused by some config I haven't done, but I am unsure as to what exactly.

3
Do you have any sort of logging enabled? Something that will show the actual exception being thrown?Neil
no i dont - like i said i am new to .net core! i know how to turn on detailed logging in .net framework web.config, but i guess its different in .net core sites?Mike Sowerbutts
Are you using IIS as reverse proxy? Could you please provide code of your web.config, your startup.cs and program.cs? Does your wwwroot folder contain an index.html?alsami
Is your API in the same project as your website? Have you tried running it without the virtual application on Azure?Brad

3 Answers

2
votes

The problem is that you "Sub-Application" has an web.config file generated that has a duplicate entry in it the parent web.config already has:

<system.webServer>
<handlers>
  <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>

See this article here: https://github.com/aspnet/IISIntegration/issues/190

0
votes

In your Startup.cs, you will probably have something like:

if (env.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
}

Just comment out the if, and you will get the developer exception page in 'production'.

That might give you a clue as to what the real problem is.

0
votes

In addition to what @Neil said, enable startup errors because the application might already fail to boot which will cause no developer exception page to be shown at all.

In your program.cs adjust the webhost build process

        return WebHost.CreateDefaultBuilder(args)
            .CaptureStartupErrors(true) // add this line
            .UseSetting(WebHostDefaults.DetailedErrorsKey, "true") // and this line
            .UseKestrel()
            .UseStartup<Startup>()
            .Build();

reference: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/hosting?tabs=aspnetcore2x#capture-startup-errors