Publishing ASP.NET Core MVC Web App Woes

Smackey01 21 Reputation points
2021-11-15T19:08:56.353+00:00

Hello all- So i'm having a heck of a time publishing my ASP.Net Core MVC Web app. I've downloaded all of the necessary IIS requirements as well as SDK and .Net Webhosting. I've followed the instructions on publishing my app via Visual studio to a specific folder under 'wwwroot' as well as deployment via IIS and assigned port 8082. While the website loads and I can 'explore' under IIS, when I try to access one of my model index pages or other 'views', I get an error (see picture ). I would also add the app works perfectly when I run it using 'IIS Express' under VS before publishing, please see picture

Any Advise or guidance would be very much appreciated!

149437-img-2923.jpeg

Internet Information Services
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,134 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,243 questions
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 47,711 Reputation points
    2021-11-15T21:38:51.083+00:00

    You're getting a server error which means your app is running but throwing an exception. Since you don't have debugging turned on you cannot see the actual error information. The easiest option is to follow the instructions given on the UI page and temporarily set the ASPNETCORE_ENVIRONMENT environment variable to 'Development'. You are most likely using the standard ASP.NET COre template that enables exception details pages in this mode so you can see the actual error.

    Note that changing an environment variable requires at least the app pool to be restarted but if you make that change in Environment Variables \ System then you'd need to reboot the system, in my experience. A cleaner way might be to temporarily change IIS's applicationhost.config file instead as discussed here.

    Or perhaps an even easier approach is to create a "legacy" web.config and drop it into your app's root as discussed in the same article. Then when you're done you can remove the file.


1 additional answer

Sort by: Most helpful
  1. Smackey01 21 Reputation points
    2021-11-17T18:23:44.557+00:00

    So I switched my project's environment in Visual Studio to 'Development', published it again and recevied the same error as stated above when I navigated to another model or view.

    1) Next I edited the Web.config file in the app's root folder by adding the below code and restarted IIS. When I attempted to launch the site I received a '500.19' error so I removed it the code.
    ' <environmentVariables>
    <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
    </environmentVariables>'.

    2) I then Edited the most recent .pubxml file for the project under Visual Studio with this entry
    '<PropertyGroup>
    <EnvironmentName>Development</EnvironmentName>
    </PropertyGroup>'

    I then restarted IIS, removed the old site from IIS and created a new one, tried to launch it and I'm still received the error from my original question ( above needing to switch to 'Development' mode) when I navigated to another model or view.

    I must be missing something very basic