question

DmitriyReznik-4665 avatar image
0 Votes"
DmitriyReznik-4665 asked JasonPan-MSFT commented

Configuring a default document for Blazor app deployment

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.

dotnet-aspnet-core-blazor
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JasonPan-MSFT avatar image
1 Vote"
JasonPan-MSFT answered JasonPan-MSFT commented

Hi @DmitriyReznik-4665

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


6.gif (471.4 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @JasonPan-MSFT ,

Thank you very much for your answer. There is only one item in the wwwroot: Publish Artifact, which is empty, as well as all folders in the level above. Can you explain this?
The app was successfully deployed:

119038-image.png

P.S. We use DevOps for deployment.


Regards,
Dmitriy


0 Votes 0 ·
image.png (38.8 KiB)

@DmitriyReznik-4665 This official article should useful to you. Please check it.


0 Votes 0 ·