Home > Blockchain >  IIS ASP.NET Core 6 Hosting Pack resulting in default document/directory listing error
IIS ASP.NET Core 6 Hosting Pack resulting in default document/directory listing error

Time:10-26

I'm attempting to get IIS to serve our ASP.NET 6 web application, but every time it complains of needing a default document. If I run the exe (kestrel) one it will serve it, but we want it to be hosted by IIS with the other components of the site.

I installed the 6.0.10 runtime w/ hosting package and these are the results when listing runtimes:

enter image description here

When looking at the site modules, I think it should have what is needed (think the AspNetCoreModuleV2 one handles the compiled routing scenario?):

enter image description here

Have rebooted the server and the app pool specifically, set to No Managed Code, and whenever I attempt to load the page at the localhost level, I get:

enter image description here

The views are compiled so I don't think I even need IIS to open views locally in any capacity.

CodePudding user response:

Everything you've posted ticks off the major deployment steps for hosting a .NET 6 project on IIS:

  • Installed the .NET Core 6.0 Runtime Windows Hosting Bundle
  • Set up the IIS app pool with "No Managed Code"
  • Rebooted the server: "Have you turned it off and on again?"

After our exchange in the comments, the only thing that appeared to be missing is to use the .NET publish command; not the build command.

When deploying to IIS, you'll want to run the dotnet publish command and then deploy those artifacts to your IIS server. From the docs:

The dotnet publish command's output is ready for deployment to a hosting system (for example, a server, PC, Mac, laptop) for execution. It's the only officially supported way to prepare the application for deployment. Depending on the type of deployment that the project specifies, the hosting system may or may not have the .NET shared runtime installed on it.

You also may want to review: Publish .NET apps with the .NET CLI.

  • Related