node.js 推送到 Windows Azure 后出现错误:您无权查看此目录或页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11461338/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 16:01:38  来源:igfitidea点击:

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

windowsnode.jsazure

提问by DasBoot

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

在过去的 3 个小时里,我在谷歌上搜索,但没有发现关于 windows azure 问题的解决办法:

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.

我对azure做了一个git master push,部署成功。我还打开了失败的请求跟踪,但除了上面的语句外没有任何显示。

Any ideas on how to troubleshoot this?

有关如何解决此问题的任何想法?

回答by AvkashChauhan

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:

我刚刚测试过,如果您不将主 node.js 文件部署为 server.js,您将收到此错误,因为 web.config 专门查找 server.js,如下所示:

  <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.

要进一步解决此问题,您可以按照此处所述通过 FTP 访问该网站。

回答by Ben Anderson

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

AvkashChauhan 的回答确实将我引向了正确的方向,但我还必须添加适当的重写规则。这是我完整的 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>

回答by Colin

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:

我也遇到了这个错误。我正在使用 MVC,错误的原因是在我的布局页面上,我调用了匿名用户无法访问的操作:

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

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

有关信息,我AuthorizeAttribute()在 Application_Start 中注册了一个全局过滤器,并且我的Login操作被修饰为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:

我的网站以前确实在 IIS7 上运行过,但 Azure 不太宽容。我通过添加这样的检查解决了这个问题:

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

回答by Hulvej

The azure tools have changed a lot since this question.

自从这个问题以来,azure 工具已经发生了很大变化。

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.

我建议人们使用azure-cli。但有趣的是,在我使用它创建了一个网站之后,我实际上并没有使用它。

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.

我现在使用的只是将 (git) 直接推送到名为 azure 的远程的能力,而 cli 正在为您进行设置。

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

但是,如果您不想安装 cli,您基本上可以手动添加远程仓库(您的站点),如下所示:

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

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.

就像您使用其他所有 git remote 一样。

回答by Vivek Kodira

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

并非特定于 node.js,而是更新以防它帮助其他人在常规 Web 应用程序中面临此问题。如果 index.html 文件不存在或未找到,因为它位于子目录中,也会发生这种情况

回答by user2314737

I had the same error message after a git pushfrom a local repository.

git push来自本地存储库之后,我收到了相同的错误消息。

Solved it by opening the Azure dashboard:

通过打开 Azure 仪表板解决了它:

Web app / App deployment / deployment source

Web 应用程序/应用程序部署/部署源

and selecting local git repositoryas deployment source

并选择本地 git 存储库作为部署源

回答by Illuminati

I just came across this issue and in my case it was the ipSecurity configuration that was causing the issue. Just hd to go and change the allowUnlisted to true.

我刚刚遇到了这个问题,就我而言,是 ipSecurity 配置导致了这个问题。只需 hd 将 allowUnlisted 更改为 true。

 <security>
   <ipSecurity allowUnlisted="false"> 
 </security>

回答by user1718248

You need to move your server.jsfile to your root app folder.

您需要将server.js文件移动到根应用程序文件夹。

回答by zahra ali

Simple configuration, in the azure portal go to your web app -> All settings -> application settings, under default documents add the specific name of your document which you want to view, wait for it to update, then refresh your azure link.

简单配置,在azure门户中转到您的Web应用程序->所有设置->应用程序设置,在默认文档下添加您要查看的文档的特定名称,等待它更新,然后刷新您的azure链接。