Getting error after pushing to Windows Azure: You do not have permission to view this directory or page

33,119

Solution 1

I just tested that if you don't deploy your main node.js file as server.js you will get this error because the web.config is specifically looking for server.js as below:

  <handlers>
       <add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
 </handlers>

To further troubleshot this issue you can access the website over FTP as described here.

Solution 2

AvkashChauhan's answer did lead me in the right direction but I also had to add proper rewriting rules. Here is my complete web.config

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation batch="false" />
  </system.web>
  <system.webServer>
    <handlers>
      <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
    </handlers>
    <rewrite>
      <rules>
        <rule name="myapp">
          <match url="/*" />
          <action type="Rewrite" url="server.js" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Solution 3

The azure tools have changed a lot since this question.

I recommend people using the azure-cli. But funny enough I actually don't use it after I have used it once to create a site.

What I use now is just the ability to push (git) directly to a remote that is named azure, and the cli is setting that up for you.

But if you don't want to install the cli you can essentially just add the remote repo (your site) manually, like this:

git remote add azure https://<site-or-appservice-name>.scm.azurewebsites.net/<site-or-appservice-name>.git

As you would with every other git remote.

Solution 4

I hit this error too. I am using MVC and the reason for the error was that on my layout page I had a call to an action that isn't accessible to anonymous users:

@Html.Action("GetMenu", "Users")  

For information, I register a AuthorizeAttribute() global filter in Application_Start and my Login action is decorated with AllowAnonymous:

    [HttpPost]
    [AllowAnonymous]
    [ValidateAntiForgeryToken]
    public ActionResult Login(LoginModel model, string returnUrl)
    {

My website did work previously on IIS7, but Azure is less forgiving. I fixed the problem by adding a check like this:

@if (User.Identity.IsAuthenticated)
{
     @Html.Action("GetMenu", "Users")
}

Solution 5

Not specific to node.js but updating in case it helps others facing this issue for a regular web application. This can also happen if the index.html file is not present or is not found because it is in a sub-directory

Share:
33,119
DasBoot
Author by

DasBoot

Updated on May 24, 2020

Comments

  • DasBoot
    DasBoot almost 4 years

    I have googled for the past 3 hours and found nothing on what to do with respect to the windows azure problem:

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

    I did a git master push to azure and the deployment was successful. I also turned on the failed request tracing but nothing shows up but the above statement.

    Any ideas on how to troubleshoot this?