2011-04-26 5 views
2

하나의 메인 마스터 페이지와 3 개의 마스터 페이지가 있습니다. 내 사이트는 사용자의 상태 (로그 아웃, 관리자 권한없이 로그인, 관리자 권한으로 로그인)에 따라 마스터 페이지를 변경하여 사이드 메뉴를 적절하게 변경합니다.로그 아웃 후 CSS 렌더링 문제

로그인하면 마스터 페이지 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> 

normaluser.master :

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

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> 
<link 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="Schedule.aspx" class='menuItem'>My Schedule </a></div> 
     <div class='menuItem'> <a href="MyProfile.aspx" class='menuItem'>My Profile </a></div> 
     <div class='menuItem'> <a href="DocManagerUser.aspx" class='menuItem'>Document Center </a></div> 
     <div class='menuItem'> <a href="Directory.aspx" class='menuItem'>Directory</a></div> 
     <div class='menuItem'> <a href="Logout.aspx" class='menuItem'>Log out </a></div> 
</asp:Content> 
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> 
    <asp:ContentPlaceHolder id="mainContent" runat="server"> 

    </asp:ContentPlaceHolder> 
</asp:Content> 

loggedout.master : 함께 또는 "서버 RUNAT ="없이

<%@ 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> 

, 스타일 시트 링크 loggedout은 아무 것도하지 않습니다. 그것을 추가하는 것이 하나의 방법이었습니다. 모든 마스터 페이지와 스타일 시트는 같은 폴더에 있습니다.

+1

web.config에서 변경해야 할 액세스 권한 일 수 있습니까? 로그 아웃 한 사용자는 loggedout.master 파일이나 css 파일에 액세스 할 수 없습니까? – Niklas

+0

와우. 예. 스타일 시트에 대한 액세스를 방해한다고 생각조차하지 않았습니다. 잘 했어. – Yamikuronue

답변

3

설명을 고려할 때 CSS는 인증을 통해 보안이 설정된 디렉토리에있는 것처럼 보입니다. 로그인 및 기타 인증되지 않은 페이지에서 CSS와 스크립트를 사용할 수있게하려면 인증을 넘어서 사용할 수 있도록해야합니다.

이렇게하려면 CSS와 스크립트 등을 디렉토리에 추가하고 (예 : 루트의 공용 폴더) web.config의 location 요소를 사용하여 모든 디렉터에게 액세스 권한을 제공 할 수 있습니다. 이것은 귀하의 보안과 관련하여 타협하지 않습니다.

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