开发者

Allow anonymous access to Content and Script folder

开发者 https://www.devze.com 2023-03-05 06:20 出处:网络
I am building a ASP.NET MVC 2 website that uses Forms authentication. Now I want to allow unauthenticated users access to the Scripts and Content folders, so the stylesheets and images will load. Howe

I am building a ASP.NET MVC 2 website that uses Forms authentication. Now I want to allow unauthenticated users access to the Scripts and Content folders, so the stylesheets and images will load. However, it does not work. From what I found on Google, this should work:

<location allowOverride="false" path="Content">
    <system.web>
      <authorization>
        <allow users="?" />
      </authorization>
    </system.web>
  </location>
  <location allowOverride="false" path="Scripts">
    <system.web>
      <authorization>
        <allow users="?" />
      </authorization>
  开发者_C百科  </system.web>
  </location>

It does not work in ASP.NET MVC 2 on IIS (win7). The stylesheet and javascript requests are redirected to Account/LogOn. How do I fix this?

Update: Anonymous Authentication is enabled in IIS. So is forms authentication.


Don't use the Authorization tags in the web.config. Use the Authorization attribute in your Controllers (or Actions).

0

精彩评论

暂无评论...
验证码 换一张
取 消