将 JS 文件添加到 web.config 中用于表单身份验证的例外文件列表中会导致无限重定向

Adding JS files to list of excepted files for forms authentication in web.config causes infinite redirect

本文关键字:文件 列表 重定向 无限 表单 添加 JS web config 用于 身份验证      更新时间:2023-09-26

我想将JS文件添加到登录页面。因此,请包含如下文件:

<script type="text/javascript" src="~/Scripts/Functions/AppLocation.js"></script>

在 web.config 中:

<location path="Scripts">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>

但是当我定向到登录页面时,它是:

http://localhost:21206/en-GB/Login?ReturnUrl=%2f

它在 URL 上执行重定向循环,如下所示:

http://localhost:21206/en-GB/Login?ReturnUrl=%2fen-GB%2f%5bobject+Object%5d

我错过了什么?

看起来框架正在尝试转到登录页面,但由于权限不足而被重定向。您是否确保您的登录页面不需要身份验证?这肯定会导致它进入无限循环。