IIS will not recognize the default document for an ASP.NET Core Web App (Razor Pages)

Dyllan Jones 20 Reputation points
2024-06-18T13:43:10.6+00:00

I created an ASP.NET Core Web App (Razor Pages) app in Visual Studio 2022. The site works when debugging on my local machine. It starts, redirects to my AAD login screen, and then forwards the user to the Index.cshtml page as expected. However, when I install it on my web server in IIS, I get a 403.14 Forbidden error: A default document is not configured for the requested URL. How do I get IIS to locate the Index.cshtml file? Everything for the app is pretty much using the default template the Visual Studio provides. The Index.chstml file is located within the Pages folder of the project, the Program.cs file has app.MapRazorPages included, and I have installed the .NET hosting bundle 8.0.6 on the web server.

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,315 questions
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 59,551 Reputation points
    2024-06-18T15:38:09.9033333+00:00

    did you create an application in IIS? also check that the publish deployed the web.config used by IIS to host the asp.net app (the web.config configures using the host module).

    note: with a razor page app, the app controls default routing rather than IIS. IIS routes the request to the hosting module, which passes the request to the razor app.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful