javascript - 允许使用 index.html 和 web.config 访问特定页面的匿名客户端
问题描述
我有一个 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 路径,只保留了不需要身份验证的主页。通过此更改,我无需身份验证即可访问主页,但它也不会显示任何其他选项卡。
我的要求是不删除其他选项卡,所有选项卡都应该可见。但是应该允许任何未经身份验证的人访问主页,当用户单击任何其他选项卡时,它应该要求进行身份验证。我如何实现这一目标?
解决方案
推荐阅读
- apache-spark - 如何彻底清理 Spark Session?
- xcode-instruments - Instruments 9.2 字体大小
- python - 如何从 Python 中多列中的行组中找到 2 个最大值,并显示其行和列索引而不重复
- java - MySQL 有一个包含 2 列的表。如何生成只有单列的列表?
- python - 我无法在我的 python 代码上显示输出以进行网络监控。不显示结果但没有错误
- vba - 从编号列表中的项目符号列表中的最后一行删除段落标记,而不会破坏最后一个项目符号/编号
- message-queue - Apache Airflow 中的实时更改工作队列
- laravel - 遵循模块化方法时如何处理 SPA?
- git - 如何在 Jira 中重新打开我自己创建和关闭的问题?
- google-chrome-extension - 如何更改按钮单击时弹出的 html