I am new to ASP.Net Core and trying to host my first simple MVC app in IIS. I have installed the IIS hosting bundle; published my MVC project to a folder using Visual Studio and then, created an IIS website with it's physical path set to the published folder. When I test it using url http://localhost:5008/home/CallApi, however, I am getting a 500 error that says "This page isn't working. localhost is currently unable to handle this request.". I can run the MVC app from within VS (selfhost, not through IIS, on a different port), it works fine there. What am I doing wrong here?
If you want to deploy ASP.Net Core MVC applications to IIS, you need to install the .NET Core host bundle, otherwise "500 Error" will appear. If you successfully install the .NET Core host bundle, you can find AspNetCoreModuleV2 in Modules:
Download the installer using the following link:
After adding the site, you need set the .NET CLR version to No Managed Code:
For more information about using IIS to host ASP.NET Core on Windows, you can refer to this link:
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.1
UPDATE:
I suggest you enable viewing of PII logs so that we can view more detailed information about the error:
public void ConfigureServices(IServiceCollection services)
{
IdentityModelEventSource.ShowPII = true;
....
You can refer to this link, which contains similar questions:
"InvalidOperationException: IDX20803: Unable to obtain configuration from: '[PII is hidden]'"
For those with the same issue, I found that no setup guide I found mentions what was, for me, a required step:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.