/ / Problem z renderowaniem CSS po wylogowaniu - asp.net, html, css, visual-studio

Problem z renderowaniem CSS po wylogowaniu - asp.net, html, css, visual-studio

Mam jedną główną stronę główną i trzy, które dziedzicząz tego; moja strona zmienia strony główne w oparciu o stan użytkownika (wylogowany, zalogowany bez uprawnień administratora, zalogowany z uprawnieniami administratora), aby odpowiednio zmienić menu boczne.

Po zalogowaniu strony wzorcowe normaluser.master i admin.master działają dobrze.

Kiedy się wylogowałem, loggedout.master nie renderuje css z arkusza stylów, zamieniając moje ładne menu boczne w listę podkreślonych niebieskich linków i usuwając wszystkie style nagłówków.

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/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:

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

Z „runat = server” lub bez niego łącze arkusza stylów podczas wylogowania nic nie robi; dodając, że to był jeden ze sposobów, w jaki próbowałem to rozwiązać. Wszystkie strony wzorcowe i arkusz stylów znajdują się w tym samym folderze.

Odpowiedzi:

3 dla odpowiedzi № 1

Biorąc pod uwagę twoje opisy, wygląda jak twójCSS znajduje się w katalogu, który jest zabezpieczony podczas uwierzytelniania. Aby CSS i skrypty były dostępne na stronie logowania i innych nieuwierzytelnionych stronach, musisz je udostępnić poza uwierzytelnianiem.

Aby to zrobić, możesz dodać te CSS i skryptyitp., do katalogu (powiedzmy folder publiczny w katalogu głównym) i użyj elementu lokalizacji w pliku web.config, aby zapewnić wszystkim dostęp do tych directoy. Nie wpływa to na Twoje bezpieczeństwo.

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