C#站点地图角色不起作用

时间:2016-05-09 17:24:13

标签: c# visual-studio-2013 sitemap

当我添加到web.config:

<siteMap defaultProvider="XmlSiteMapProvider" enabled="true" >
  <providers>
    <add name="XmlSiteMapProvider"
         description="Domyślny dostawca mapy serwisu."
         type="System.Web.XmlSiteMapProvider"
         siteMapFile="Web.sitemap"
         securityTrimmingEnabled="true" />
  </providers>
</siteMap>

网站显示不正确(菜单已隐藏)。

Web.sitemap中:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode>
    <siteMapNode url="~/Default.aspx" title="Strona główna" description="Przenieś do strony głównej" roles="*"/>
  </siteMapNode>
</siteMap>

的Web.config:

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="AdventureWorksLT_DataConnectionString" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\AdventureWorksLT_Data.mdf;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.web>
    <authentication mode="Forms">
      <forms loginUrl="~/Zaloguj.aspx" />
    </authentication>

    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E129"/>
      </assemblies>
    </compilation>

    <pages theme="CzerwonaSkorka"/>
    <httpRuntime targetFramework="4.5"/>

    <roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
      <providers>
        <add name="CustomizedRoleProvider" type="System.Web.Security.SqlRoleProvider" applicationName="AdventureWorks" connectionStringName="AdventureWorksLT_DataConnectionString" />
      </providers>
    </roleManager>

    <membership defaultProvider="CustomizedMembershipProvider">
      <providers>
        <add name="CustomizedMembershipProvider" type="System.Web.Security.SqlMembershipProvider" applicationName="AdventureWorks" connectionStringName="AdventureWorksLT_DataConnectionString" />
      </providers>
    </membership>

    <siteMap defaultProvider="XmlSiteMapProvider" enabled="true" >
      <providers>
        <add name="XmlSiteMapProvider"
             description="Domyślny dostawca mapy serwisu."
             type="System.Web.XmlSiteMapProvider"
             siteMapFile="Web.sitemap"
             securityTrimmingEnabled="true" />
      </providers>
    </siteMap>

  </system.web>

  <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
  </appSettings> 
</configuration>

@EDIT 主:

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

<%@ Register src="Kontrolki/Kategorie.ascx" tagname="Kategorie" tagprefix="uc1" %>

<%@ Register src="Kontrolki/NoweProdukty.ascx" tagname="NoweProdukty" tagprefix="uc2" %>

<%@ Register src="Kontrolki/WybraneProdukty.ascx" tagname="WybraneProdukty" tagprefix="uc3" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Adventure Works</title>
    <link href="App_Themes/NiebieskaSkorka/Style.css" rel="stylesheet" />
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div id="Strona">
            <div id="Nagowek">
                <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/AWlogo.jpg" />
                <div id="Menu">
                    <asp:SiteMapDataSource ID="MapaSerwisu" runat="server" ShowStartingNode="False" />
                    <asp:Menu ID="MenuGlowne" runat="server" DataSourceID="MapaSerwisu" Orientation="Horizontal">
                        <DynamicHoverStyle CssClass="ZaznaczonyElementMenu" />
                        <DynamicMenuItemStyle CssClass="ElementMenuRozwijanego" />
                        <StaticHoverStyle CssClass="ZaznaczonyElementMenu" />
                        <StaticMenuItemStyle CssClass="ElementMenuNadrzednego" />
                    </asp:Menu>
                </div>
                <div id="ObszarLogowania">
                    <asp:LoginView ID="LoginView1" runat="server" OnViewChanged="LoginView1_ViewChanged">
                        <AnonymousTemplate>
                            <a href="Zarejestruj.aspx">Zarejestruj</a>
                        </AnonymousTemplate>
                        <LoggedInTemplate>
                            Witaj
                            <asp:LoginName ID="LoginName1" runat="server" />
                        </LoggedInTemplate>
                    </asp:LoginView>|
                    <asp:LoginStatus runat="server" CssClass="LinkObszaruLogowania" LoginText="Zaloguj" LogoutAction="Redirect" LogoutPageUrl="~/Default.aspx" LogoutText="Wyloguj">

                    </asp:LoginStatus>
                </div>
            </div>
            <div id="Tresc">
                <div id="PierwszyObszarBoczny">
                    <uc1:Kategorie ID="Kategorie1" runat="server" />
                    <uc3:WybraneProdukty ID="WybraneProdukty1" runat="server" />
                </div>
                <div id="DrugiObszarBoczny">
                    <uc2:NoweProdukty ID="NoweProdukty1" runat="server" />
                </div>
                <div id="ObszarRoboczy">
                    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
                </div>
            </div>
        </div>
    </div>
    </form>
</body>
</html>

我不知道我的代码有什么问题。即使我删除role =“*”我也看不到菜单。我认为这是config中sitemap的结果。

0 个答案:

没有答案