Running Net 6 Web App on IIS

ANB 181 Reputation points
2022-01-11T17:15:33.01+00:00

I developed my API with Net 6 and I can use it locally via Swagger.

However, when I publish to IIS, I get 403.14 Forbidden.
Theoretically enabling Directory Browsing or specifying the default document (eg index.html) would resolve this error.

But being a Net 6 web api application (being a Console Application), these files don't even exist.
What exists is my .EXE project with countless other DLL's.

So, how do I run my .NET 6 Web App on IIS?

Internet Information Services
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2022-01-12T00:58:06.157+00:00

    have you installed the correct hosting .net 6.0 package for IIS on the webserver?

    https://dotnet.microsoft.com/en-us/download/dotnet/6.0

    0 comments No comments

  2. Bruce Zhang-MSFT 3,751 Reputation points
    2022-01-12T02:57:23.023+00:00

    Hi @ANB ,

    As far as I know, .NET 6 web api is a web application, not a console application.

    You can refer to this docs about 403.14 error when deploy application on IIS. You can publish it again in visual studio and re-deploy to IIS. Make sure all files are correctly.

    1.Delete all of the files and folders from the deployment folder on the hosting system.
    2.Redeploy the contents of the app's publish folder to the hosting system using your normal method of deployment, such as Visual Studio, PowerShell, or manual deployment:
    Confirm that the web.config file is present in the deployment and that its contents are correct.
    When the app is hosted by IIS, confirm that the app is deployed to the IIS Physical path shown in IIS Manager's Basic Settings.
    3.Confirm that all of the app's files and folders are deployed by comparing the deployment on the hosting system to the contents of the project's publish folder.

    After deploying on IIS, there is no need to set its index page on Default Document. You just need to enable Directory Browsing.

    Finally, make sure the url is right. The url of Swagger Web API application is http://domain:port/swagger/index.html. Otherwise you may get 404 error.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Bruce Zhang

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.