ASPX背景图像显示在源中但不在网页中

时间:2012-01-18 03:28:26

标签: c# asp.net html

我正在使用VS2005 C#。

我有一个使用CSS背景图片的登录页面。

在我修改 web.config 以满足AD身份验证后,背景图像不再显示。

我在中查看时可以看到背景图片,但当登录页面在浏览器中查看时,背景为纯白色。

以下是我的 Login.aspx loginCSS.css Web.config 的代码段:

的Login.aspx:


<head runat="server"><link rel="stylesheet" type="text/css" href="loginCSS.css" />
    <title>Login</title>
<script language="javascript" type="text/javascript">
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div  align="center">
    <asp:Login ID="Login1" runat="server" BackColor="#F7F6F3" BorderColor="#E6E2D8" 
            BorderPadding="4" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 
            Font-Size="Small" ForeColor="#333333" Height="130px" 
            Width="303px">
          <TextBoxStyle Font-Size="Small" />
          <LoginButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid" 
              BorderWidth="1px" Font-Names="Verdana" Font-Size="Small" ForeColor="#284775" />
          <InstructionTextStyle Font-Italic="True" ForeColor="Black" />
          <TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" Font-Size="Small" 
              ForeColor="White" />
        </asp:Login>

</div>
    </form>
</body>
</html>

LoginCSS.css


body 
{
    background-image:url('images/loginbackground.png');
    background-repeat:no-repeat;
    background-attachment:fixed;
}

的Web.config:


<authentication mode="Forms">
            <forms name=".ADAuthCookie" timeout="10" loginUrl="Login.aspx" defaultUrl="~/Common/Default.aspx">
            </forms>
        </authentication>

我可以知道出了什么问题吗?有没有更好的方法在我的登录表单中显示背景图像?

1 个答案:

答案 0 :(得分:4)

听起来您可能需要对CSS或图像文件进行身份验证。

尝试添加

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

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

这将为您提供任何权限,无需登录即可检索您的CSS /图像