CSS未加载表单身份验证

时间:2011-06-27 19:12:02

标签: c# asp.net web-config forms-authentication

我在很多网站上看到了其中的几个主题,但我仍然遇到了问题。我已将此添加到</configuaration>

之前的web.config底部
  <location path="Form.css">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>

然而我的css仍然没有为所有用户加载。

以下是我的web.config

的表单部分
<authentication mode="Forms">
      <forms name ="WebApp.ASPXAUTH"
            loginUrl="login.aspx"
             protection="All"
             path ="/"/>
    </authentication>
    <authorization>
      <allow users ="*"/>
    </authorization>

我还缺少其他什么吗?

3 个答案:

答案 0 :(得分:8)

我在css文件夹中放入了一个带有该代码的web配置:

<?xml version="1.0"?>
<configuration>

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

</configuration>

成功! :)

答案 1 :(得分:4)

将您的CSS放在一个不受保护的文件夹中,这应该适合您。

<link rel="stylesheet" src="path of the stylesheet" type="text/css"> 

答案 2 :(得分:0)

对我来说,它的工作原理包括访问web.config中的资源文件夹(内容,脚本)。

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

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