忽略要进行身份验证的文件扩展名

时间:2013-08-16 20:51:59

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

我实现了this code来在运行时压缩来自我网站的JS文件。

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

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

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

JS文件正常打开。但我不想为我网站上的每个JS文件执行此操作。

如何制作任何JS需要身份验证?

谢谢。

1 个答案:

答案 0 :(得分:0)

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

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

<location path="scripts">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
相关问题