简体   繁体   English

访问被拒绝 - 401.2:未经授权的错误

[英]Access is Denied - 401.2: Unauthorized Error

I have an ASP.NET website hosted on IIS 7.5 as below:我在 IIS 7.5 上托管了一个 ASP.NET 网站,如下所示:

I have "customwebsite.com" as the website and in it I have two Web Applications - uk & us - so that I can access these application as customwebsite.com/uk & customwebsite.com/us.我有“customwebsite.com”作为网站,其中我有两个 Web 应用程序——英国和我们——这样我就可以访问这些应用程序作为 customwebsite.com/uk 和 customwebsite.com/us。

customwebsite.com directory does not have any web.config and have only two folders for web application us and uk. customwebsite.com 目录没有任何 web.config 并且只有两个用于 web 应用程序 us 和 uk 的文件夹。

Both us and uk web application have their individual web.config and have Form Authentication specified as below:我们和英国的 Web 应用程序都有各自的 web.config 并具有如下指定的表单身份验证:

    <authentication mode="Forms">
      <forms loginUrl="/static/login.aspx" name="login" timeout="20"/>
    </authentication>

    <authorization>
      <deny users="?" />
    </authorization>

At this path: /static, there is a web.config with following content:在这个路径:/static,有一个web.config,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
        <authorization>
            <allow users="?" />
        </authorization>
    </system.web>
</configuration>

When I hit the root URL for us application, the Website loads correctly but if I loads from uk, I got the error as below:当我点击我们应用程序的根 URL 时,网站加载正确,但如果我从英国加载,我收到如下错误:在此处输入图片说明

I have checked the Folder Security, and all the required users have been granted permission and are same for both us and uk applications.我已经检查了文件夹安全性,并且所有必需的用户都已被授予权限,并且对于我们和英国的应用程序都是相同的。

I have checked the IIS logs and below is the response codes of the request in case of failure: 401 0 0 1519 296我检查了 IIS 日志,下面是失败时请求的响应代码:401 0 0 1519 296

Can someone help me resolving this issue.有人可以帮我解决这个问题。

Got it resolved.得到了解决。

There was two more folders where the redirection of /static/login.aspx happens.还有两个文件夹发生了 /static/login.aspx 的重定向。

We need to allow access to all such redirecting folders by having a web.config files in those folders with below content:我们需要通过在这些文件夹中包含具有以下内容的 web.config 文件来允许访问所有此类重定向文件夹:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
        <authorization>
            <allow users="?" />
        </authorization>
    </system.web>
</configuration>

Ran into this same error, but had a different resolution.遇到了同样的错误,但有不同的解决方案。 In our case we had to set:在我们的例子中,我们必须设置:

<machineKey compatibilityMode="Framework45" />

Details here:http://ardalis.com/asp-net-shared-authentication-problem-solved详情请见:http ://ardalis.com/asp-net-shared-authentication-problem-solved

In our case we had an error on the login page that redirected to the an error page that the user did not have rights to see, so it redirected to the login page... cycle rinse repeat.在我们的例子中,我们在登录页面上有一个错误,重定向到用户无权查看的错误页面,因此它重定向到登录页面......循环冲洗重复。

We removed all the controls from the UI, then added them back one by one until the page crashed.我们从 UI 中删除了所有控件,然后将它们一一添加回来,直到页面崩溃。 Then we could narrow down the controls that had an error.然后我们可以缩小出现错误的控件的范围。

And yes, we gave all users access to the error page.是的,我们允许所有用户访问错误页面。

Check below IIS setting检查以下 IIS 设置

  1. Authorization Rules -must contain only allow user setting not any any other rule ex.授权规则 - 必须只包含允许用户设置而不是任何其他规则,例如。 deny user rule.拒绝用户规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM