【问题标题】:Ignoring a file extension to be authenticated忽略要验证的文件扩展名
【发布时间】:2013-08-16 20:51:59
【问题描述】:

我实现了this code 在运行时从我的站点压缩 JS 文件。

但现在我所有的 JS 文件都重定向到登录页面。

如果我将它添加到 web.config:

  <location path="asd.js" allowOverride="false">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>

JS文件正常打开。但我不想对我网站上的每个 JS 文件都这样做。

如何让任何 JS 都需要认证?

谢谢。

【问题讨论】:

    标签: asp.net authentication web-config iis-6 forms-authentication


    【解决方案1】:

    最好的解决方案是将所有“忽略”文件放在某个目录中,然后在路径中为整个目录添加一个例外。请参阅下面的类似问题和解决方案:

    ASP.NET Forms Authentication prevents loading javascript on Login.aspx

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-07
      • 2018-11-26
      • 1970-01-01
      • 2014-02-14
      • 2018-09-20
      • 2011-04-07
      相关资源
      最近更新 更多