允许使用index.html和web.config访问特定页面的匿名客户端

时间:2019-06-12 04:03:19

标签: javascript c# angularjs

我有一个Web应用程序,我想在其中加载主页以及另外一个页面,以便无需身份验证即可通过匿名访问,而对于其他页面,则需要身份验证。在webconfig文件中,我做了以下更改。但我仍然可以在主页上看到它要求提供凭据。

 <location path="app/components/home/home.html">
<system.web>
<authorization>
<allow users="*"/> 
</authorization>
</system.web>
</location>
<system.web>
<authorization>
      <allow roles="BUILTIN\Administrators" />
      <deny users="?" />
    </authorization>
</system.web>
<location path="app/components/home/home.html">
<system.webServer>
    <security>
      <authentication>
        <anonymousAuthentication enabled="true" />
        <basicAuthentication enabled="false" />
        <windowsAuthentication enabled="false" />
      </authentication>
 </security>
</system.webServer>
<location path="app/components/home/home.html">
<system.webServer>
    <security>
      <authentication>
        <anonymousAuthentication enabled="false" />
        <basicAuthentication enabled="false" />
        <windowsAuthentication enabled="true" />
      </authentication>
 </security>
</system.webServer>

我的项目中有index.html,如下所示:

<!DOCTYPE html>

<html>
<head>
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <link rel="icon" type="image/png" href="app/assets/img/favicon.ico">
    <!-- font-awesome -->
    <link href="" rel="stylesheet" />


    <link href="app/app.css" rel="stylesheet" />
    <link href="app/components/home/home.css" rel="stylesheet" />
    <link href= "othersheets"/>
    <link href="othersheets"/>
    <link href="othersheets"/>

 <script src="app/assets/vendor/scripts/jquery.min.js"></script>
    <script src="app/assets/vendor/scripts/jquery-ui.min.js"></script>
    <script src="app/assets/vendor/scripts/angular.min.js"></script>
    <script src="app/assets/vendor/scripts/angular-ui-router.min.js"></script>

<script src="app/components/home/home.js"></script>
<script src="otherjs files"></script>

</head>
<body ng-app="dApp">
    <dcheader></dcheader>
    <div class="main-content">
        <side-nav></side-nav>
        <div class="right-pane">
            <main ui-view class="content"></main>
            <dcfooter></dcfooter>
        </div>
    </div>
</body>
</html>

我删除了所有需要身份验证的所有其他页面的链接href和脚本src路径,只保留了不需要身份验证的主页。进行此更改后,我无需身份验证即可访问主页,但是它也不会显示任何其他标签。

我的要求是不删除其他选项卡,所有选项卡都应该可见。但是,未经身份验证的任何人都应允许访问主页,当用户单击任何其他选项卡时,都应要求身份验证。我该如何实现?

0 个答案:

没有答案
相关问题