Configuring a default document for Blazor app deployment

Dmitriy Reznik 236 Reputation points
2021-07-28T20:16:55.863+00:00

I created a blazor server side application. Everything works on local IIS. Now I deployed the app on Azure. When I navigate to the specified url http://MyApp.azurewebsites.net, I get this error:

You do not have permission to view this directory or page.

Here is the detailed error:

HTTP Error 403.14 - Forbidden

The Web server is configured to not list the contents of this directory.

Most likely causes: A default document is not configured for the requested URL, and directory browsing is not enabled on the server.

So my question is: how I can specify the default document for deploying Service App on Azure? It should be Index.razor, that contains

@page "/"

As Index.razor is compiled into a dll, it would be probably not right to add it to Default Documents in Application Settings on Azure App Service.

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,579 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JasonPan - MSFT 5,466 Reputation points Microsoft Vendor
    2021-07-29T06:18:58.967+00:00

    Hi @Dmitriy Reznik

    By default, there is no need to add a default document in the portal settings.

    In azure webapp, when encountering this problem, the first consideration is the lack of web.config file.

    Suggestion

    1. You need to open scm site, like http://MyApp.scm.azurewebsites.net, check if the web.config file exist ? 118962-6.gif
    2. If the web.config file exists and this problem occurs, you need to delete all files under wwwroot and republish it to try to solve the problem. It is recommended to use vs2019 to deploy your webapp.
    3. If it does not exist, we need to create and add a web.config file with the following format:. <?xml version="1.0" encoding="utf-8"?>
      <configuration>
      <location path="." inheritInChildApplications="false">
      <system.webServer>
      <handlers>
      <add name="aspNetCore" path="" verb="" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\WebApplication1.dll" stdoutLogEnabled="false" stdoutLogFile="\?\%home%\LogFiles\stdout" hostingModel="inprocess" />
      </system.webServer>
      </location>
      </configuration>
    4. You also can use Diagnose and solve the problem, to check the logs. Getting specific error messages will help solve the problems encountered.

    If the answer is helpful, please click "Accept Answer" and upvote it.
    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,
    Jason

    1 person found this answer helpful.

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.