54
votes

After I published an ASP.NET Core app to Azure from Visual Studio 2017 I am getting this message when I click on the app url:

enter image description here

It was working fine before. Is there some way to reset the source code or the app?

Do you have any solutions?

14
sometimes something get corrupted for some reason in the process of publishing, in my case I just had to restart my web app. App Services > Your Web App > Overview > click Restart.Antonio Correia

14 Answers

39
votes

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

That basically a hint that Azure encounter an error while running your web app. Since its in production, it does not show any useful error messages. For testing/debugging purposes you can turn on the Azure detailed messaging, and turn back off when its ready for production. To do so, you have to follow these two steps,

  • Login to Azure > App Services (left side menu) > Your Web App > App Service logs (search box is at the top if you can't find it), then turn on Detailed Error Messages or turn on all of the logging options, up to you.
  • Now add the following in your Web Config file,
  • In your Web Config file add <customErrors mode="Off" /> BEFORE system.web closing tag, </system.web>. Similarly, add <httpErrors errorMode="Detailed"></httpErrors> BEFORE </system.webServer>. Finally, upload the Web Config to Azure and cross your fingers.

If you follow the steps correctly, that will show the error messages in detail and hopefully from there you will figure out what went wrong. Good Luck!

9
votes
  • The fist thing you should do is actually go and check the folders if your war got unpacked inside the webapps folder. for that if your web url is "xyz.azurewebsites.net" then try to open xyz.scm.azurewebsites.net. This should redirect you to KUDU interface where you can see few tabs. From those tabs select Debug Console and then select CMD from the drop down. This should give you a folder structure.Now Go to site->wwwroot->webapps . There check if your war got unpacked.
  • If not then try restarting the web app and see id this does the trick. If while creating your app service plan you have selected the Standard pricing tier, change it to premium
  • Last but not the list you can enable logging for you app. Then go to Monitoring-> Diagnostics logs . Turn those setting on. Then select Log streaming(Just below Diagnostics logs).

Hope this help.

7
votes

From my experience, if your login user ID under Azure Active Directory (AAD), you have to modify in Settings:

  • Authentication / Authorization
  • App Service Authentication, "ON" =>> choose: Log in With Azure Active Directory
  • Select 'ActivityProvider', base on your purpose. In my case, I'm using AAD.
  • Configured (Express: Existing APP)
  • Manage Azure Active Directory: Manage Permission & Manage Application

For Manage Permission ==>> Add, In Delegate Permission, choose: Sign in and read user profile and refresh your browser to login again

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

This message show when you have restrict ip on IIS config. Check your Web.config file and add your ip address in security section like below:

<security>
<ipSecurity allowUnlisted="false">
<clear />
<add ipAddress="192.168.250.70" allowed="true" />
</ipSecurity >
</security>

Remove it if you do not want to restrict any ip address.

3
votes

In fact , you need to upload your index.php file direct to wwwroot (inside "site" foler)

2
votes

From the error description, it is not very clear about what went wrong here.

You may check whether the deployed files are available or not using Kudu Console.

Also, make sure that your startup file (For ex: index.htm) is added to the default documents section.

I would suggest you refer Enable diagnostics logging for web apps in Azure App Service and Troubleshoot ASP.NET Core on Azure App Service to check the complete error details and root cause.

1
votes

Just to add to the solutions: in my case I updated the application but the application pool was set to "Always On" so something had "confused it". All I had to do was:

  • go to the site settings in the Azure portal
  • then select configuration under Settings
  • then select the General Settings tab on the configuration page
  • On the General settings tab switch "Always On" to Off
  • and reconnect to your site as normal.
  • When the site is back up and running switch "Always On" back to On.
1
votes

To turn errors on on production I had to set the ASPNETCORE_ENVIRONMENT environment variable to 'Development' which can be found in your app service here:enter image description here

1
votes

In my case Azure DevOps was creating deployment package within extra build folder, so path was build/wwwroot instead of just wwwroot.

I had to uncheck 'Prepend root folder name to archive paths' on my build pipeline.

devops configuration

0
votes

Another useful workaround is on the page Jimmy pointed out go to "Defaul documents" tab and add the name of your main file (it should be index.html) but if not add it.

That solved my problem.

0
votes

Some of the answers on here are more generalized, which I consider to be better overall, but if you are working with Azure Pipelines, I do know that a common scenario in deploying an Azure Web App is that the pipeline simply chooses the incorrect deployment method for the pipeline task. In most basic cases for an IIS web app, e.g. ASP.NET, you will want to use WebDeploy. Simply set the parameters below as such:

UseWebDeploy: true
DeploymentType: 'webDeploy'

See the task reference for more details: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-rm-web-app-deployment

0
votes

You are probably not zipping the right folder on your build pipeline.

I had the same problem and all I had to do to fix it was adding '/build' here:

- task: ArchiveFiles@2
  displayName: 'Archive files'
  inputs:
    rootFolderOrFile: front-end/presentation/build
    includeRootFolder: false
0
votes

We get this sometimes on build->release of a .net 4.7.2. web app (webdeploy). Rebuild/rerelease usually solves it. Restart/config changes, stop/start, nothing else works.

0
votes

I deployed straight from VS Code to Azure App Service with no pipelines set up.

In Azure in the App Service, go to configuration and under path mappings the physical path is by default set to site\wwwroot

You might need to tweak this depending on how your application structure looks like after the build

For me, since I built straight into the dist folder and my index.html is directly under that folder, I got it to work with:

site\wwwroot\dist\

But if you have the app name in the folder structure, you might need to do:

site\wwwroot\dist\<app name>\ or similar depending on where the initial file(e.g index.html) is