Visual Studio ASP.NET app precompiled publish to Azure Web App results in Forbidden except for code from one branch, one computer

1.2k Views Asked by At

I am working with an ASP.NET MVC (5/.NET Fx 4.8) application that has been deployed to Azure Web Apps for 7+ years. Yesterday, I noticed that I can only successfully publish the project to Azure Web Apps from a single computer on a single branch or earlier code on that single computer.

The deployment is reported by Visual Studio to be successful, however, there is a message in the output window after several seconds: A call to warmup your site failed with response code: 'Forbidden'.

(Update: 2023-01-22) I have now determined that this problem only occurs when the MVC project is deployed pre-compiled and merged to a single assembly. When the project is not pre-compiled, or pre-compiled but not merged to a single assembly, any computer can successfully publish any branch.

I am struggling to understand how I can make sense of this. The code is the same (according to source control) across the computers. The publish.xml file is the same across computers (until I turn off the merge option, that is).

Here are some additional observations:

  • I have run a folder diff between the working branch and the non-working branch and the only differences are found in binary files and in files containing the source code file path.
  • After the deployment that results in the 403 error ("failed deployment"), requests for static files still work. Requests for ASP.NET MVC views fail with the error (below).
  • After a failed deployment, when I access the site via FTPS, everything appears normal and in place.

Thanks for any assistance.

EDIT 1

When the deployment "fails," the browser shows this error message: You do not have permission to view this directory or page. No other content, just that line of text.

EDIT 2

When I review the application log stream in App Service, I see a more detailed error page showing that the specific HTTP error is 403.14 and appears to result from the StaticFile handler. Could it be that the web server is trying to look at the site as a static site instead of using the ASP.NET routes?

1

There are 1 best solutions below

1
Harshitha On

I have deployed the ASP.NET MVC app to Azure Web from 2 different machines without any issues.

A call to warmup your site failed with response code: 'Forbidden'.

There might be some permission issues or restricted the IP's for not to access the Application.

Make sure you do not have any Access restrictions in the deployed Azure App Service.

enter image description here

Enable the warm-up feature for the App Service.

enter image description here

  • After the deployment that results in the 403 error ("failed deployment"), requests for static files still work.

This error is caused if the application does not have sufficient permissions for accessing the files.

the other PCs older branches would have already had them cached; packages are not in source control.

As you have mentioned that there might be issue with caching the NuGet Packages. Once check the .csproj of all the applications for the NuGet Package versions.

Select the Remove additional files at destination option while publishing the app.

enter image description here

If you are still facing issues, try with the different approach to deploy the code to App Service.

  • Get the publish profile from the Overview page.

enter image description here

  • In Publish window, select the Import Profile.

enter image description here

  • Browse and select the downloaded Publish profile and continue with the next steps.

enter image description here