Asp.net 注销后CSS呈现问题

Asp.net 注销后CSS呈现问题,asp.net,html,css,visual-studio,Asp.net,Html,Css,Visual Studio,我有一个主页和三个继承主页;“我的网站”会根据用户的状态(注销、无管理员权限登录、以管理员权限登录)更改母版页,以便适当更改侧菜单 登录后,母版页normaluser.master和admin.master工作正常 当我注销时,loggedout.master无法从样式表中呈现任何css,将我的漂亮侧菜单变成带下划线的蓝色链接列表,并删除所有标题样式 MasterPage.master: <%@ Master Language="C#" AutoEventWireup="true" Cod

我有一个主页和三个继承主页;“我的网站”会根据用户的状态(注销、无管理员权限登录、以管理员权限登录)更改母版页,以便适当更改侧菜单

登录后,母版页normaluser.master和admin.master工作正常

当我注销时,loggedout.master无法从样式表中呈现任何css,将我的漂亮侧菜单变成带下划线的蓝色链接列表,并删除所有标题样式

MasterPage.master:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body style="background-color: rgb(231, 231, 255);height:100%;margin:0px;padding:0px">
    <form id="form1" runat="server">
    <div style="background-color:rgb(74, 60, 140);color: rgb(247, 247, 247);height:20%">
        <div style='width:7%;display:inline-block;border:none;padding:0px;padding-left:2px'>
            <img src="Images/globe2.png" style="height:100px;vertical-align:middle"/>
        </div>
        <div style='display:inline-block;vertical-align:middle;'>
            <span style='font-size:36pt;padding-left:10px;font-family:Century,inherit'> Welcome To MeetSmart: </span><span style="font-size:16pt;font-style:italic"> Your smarter meeting solution</span>
        </div>
    </div>
    <div style="height:80%">
        <div style='width:15%;height:100%;display:inline-block;text-align:center;margin-top:10px;padding:0px;'>
            <asp:ContentPlaceHolder id="Menu" runat="server">

            </asp:ContentPlaceHolder>

        </div>
        <div style='display:inline-block;margin:0px;padding-left:10px;padding-top:20px;border:2px solid purple;width:75%;height:100%;vertical-align:top'>
            <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

            </asp:ContentPlaceHolder>
        </div>
    </div>
    </form>
</body>
</html>



无论是否使用“runat=server”,loggedout中的样式表链接都不起任何作用;补充说这是我试图解决问题的一种方法。所有母版页和样式表都在同一文件夹中

考虑到您的描述,您的CSS似乎位于一个受身份验证保护的目录中。为了使CSS和脚本在登录和其他未经身份验证的页面上可用,您需要使它们在身份验证之外可用

要做到这一点,您可以将这些CSS和脚本等添加到一个目录(比如根目录上的公用文件夹),并使用web.config中的location元素为每个人提供对这些目录的访问。这并没有损害你的安全

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


是否需要在web.config中更改访问权限?注销的用户将无法访问loggedout.master文件或css文件?哇。是的。我甚至没有想到它会阻止对样式表的访问。干得好。
<%@ Master Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="LoggedOut.master.cs" Inherits="LoggedOut" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <link runat="server" href="StyleSheet.css" rel="stylesheet" type="text/css" />
    <title>

    <asp:ContentPlaceHolder id="title" runat="server">
    </asp:ContentPlaceHolder>
    </title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Menu" Runat="Server">
    <div class='menuItem'><a href="Login.aspx" class='menuItem'>Log In </a><br /></div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ContentPlaceHolder id="mainContent" runat="server">
    </asp:ContentPlaceHolder>
</asp:Content>
<configuration>
   <location path="Public">
      <system.web>
         <authorization>
            <allow users="*"/>
         </authorization>
      </system.web>
   </location>
</configuration>