I created a Web API in using .Net Core 3.1 using VS 2022
Nothing fancy this is just the bare bones API that we get using the template with the Weather controller to which I added Swagger. Everything works fine from VS -> IIS Express.
Tried deploying to IIS locally on my development system.
Did not work.
First is the forbidden page when browsing from IIS:
And then tried accessing swagger:
Publish Settings from VS
Did not change the defaults in Manage Application they are set to port 80 for Http and 443 to Https.
Out of curiosity I ran the executable from the publish folder, took the URL from there. This worked and the swagger page is displayed.
So either it's the port or something else that I am not able to figure out. Appreciate any clues and guidance to make this work.
Thanks in advance.
Below are the steps to publish the ASP.NET Core Web API on IIS server:
Open a project in Visual Studio, right-click on it and choose Publish option
Choose the folder option and select a target folder and publish it
Open the IIS server, right-click on the server name, and select Add Website...
Enter website name, select path, and enter a port number -> click ok
Open Application Pools, double click on you web API application pool name
From the .NET CLR version select No Managed Code
Install ASP.NET Core Hosting Bundle
Add the below code in the Program.cs
file:
if (app.Environment.IsDevelopment()|| app.Environment.IsProduction())