将菜单项绑定到站点地图

发布于 2024-09-03 01:22:20 字数 3291 浏览 3 评论 0原文

这让我抓狂。

我有一个导航菜单,我想根据用户角色(使用.net会员资格)显示一个导航菜单。经过几个小时和头痛(因为我的头撞在桌子上),我想知道是否有人可以指出我的方法错误。

页面:

<body>
    <form runat="server">
    <div class="page">
        <div class="header">
            <div class="loginDisplay">
                <asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
                    <AnonymousTemplate>
                        <a href="~/Login.aspx" ID="HeadLoginStatus" runat="server">Log In</a> 
                    </AnonymousTemplate>
                    <LoggedInTemplate>
                        Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
                        [ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/Open/Close.aspx"/> ]
                    </LoggedInTemplate>
                </asp:LoginView>
            </div>
            <div class="clear hideSkiplink">
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" 
                    IncludeStyleBlock="False" Orientation="Horizontal"
                DataSourceID="AugustSiteMap" />
                <asp:SiteMapDataSource ID="AugustSiteMap" runat="server" ShowStartingNode="false"/>
            </div>
        </div>

站点地图:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode url="~/Default.aspx" title="Home"  description="Home">

    <siteMapNode title="Open Pages" description="Open Pages">
      <siteMapNode url="~/Open/Login.aspx" title="Login Page" description="Login Page" roles="*"/>
      <siteMapNode url="~/Open/Close.aspx" title="" description="" roles="*"/>

    </siteMapNode>

    <siteMapNode title="Logged In Open Pages" description="Logged In Open Pages">
      <siteMapNode url="~/Landing.aspx" title="Landing Page" description="Landing Page" roles="*"/>
      <siteMapNode url="~/ContactUs.aspx" title="Contact Us" description="Contact Us" roles="*"/>

    </siteMapNode>


    <siteMapNode title="Restricted Pages" description="Resticted Pages">
      <siteMapNode url="~/Restricted/ProductSearch.aspx" title=" Product Search" description=" Product Search" roles="*"/>
      <siteMapNode url="~/Restricted/ReportOutput.aspx" title="Report Output" description="Report Output" roles="Admin"/>
    </siteMapNode>



  </siteMapNode>

</siteMap>

Webconfig:

<roleManager enabled="true" />
      <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
        <providers>

         <add name="XmlSiteMapProvider"
            description="AugustSiteMap"
            type="System.Web.XmlSiteMapProvider "
            siteMapFile="AugustSiteMap.sitemap"
            securityTrimmingEnabled="true" />
        </providers>
      </siteMap>

如何确保用户登录时,适当的菜单项显示在登陆页面上?

问题在于,目前导航菜单不是以任何方式、形状或形式创建的。

请原谅我的无知。对这一切还很陌生,我目前的“反复试验”方法让我今天早上达到了自杀水平!

this is driving me nuts.

I have a navigation menu I would like to display based upon user roles (using.net membership) After several hours and headaches (from banging my head against the desk) I was wondering if someone can point me in the error of my ways.

Page:

<body>
    <form runat="server">
    <div class="page">
        <div class="header">
            <div class="loginDisplay">
                <asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
                    <AnonymousTemplate>
                        <a href="~/Login.aspx" ID="HeadLoginStatus" runat="server">Log In</a> 
                    </AnonymousTemplate>
                    <LoggedInTemplate>
                        Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
                        [ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/Open/Close.aspx"/> ]
                    </LoggedInTemplate>
                </asp:LoginView>
            </div>
            <div class="clear hideSkiplink">
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" 
                    IncludeStyleBlock="False" Orientation="Horizontal"
                DataSourceID="AugustSiteMap" />
                <asp:SiteMapDataSource ID="AugustSiteMap" runat="server" ShowStartingNode="false"/>
            </div>
        </div>

SiteMap:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode url="~/Default.aspx" title="Home"  description="Home">

    <siteMapNode title="Open Pages" description="Open Pages">
      <siteMapNode url="~/Open/Login.aspx" title="Login Page" description="Login Page" roles="*"/>
      <siteMapNode url="~/Open/Close.aspx" title="" description="" roles="*"/>

    </siteMapNode>

    <siteMapNode title="Logged In Open Pages" description="Logged In Open Pages">
      <siteMapNode url="~/Landing.aspx" title="Landing Page" description="Landing Page" roles="*"/>
      <siteMapNode url="~/ContactUs.aspx" title="Contact Us" description="Contact Us" roles="*"/>

    </siteMapNode>


    <siteMapNode title="Restricted Pages" description="Resticted Pages">
      <siteMapNode url="~/Restricted/ProductSearch.aspx" title=" Product Search" description=" Product Search" roles="*"/>
      <siteMapNode url="~/Restricted/ReportOutput.aspx" title="Report Output" description="Report Output" roles="Admin"/>
    </siteMapNode>



  </siteMapNode>

</siteMap>

Webconfig:

<roleManager enabled="true" />
      <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
        <providers>

         <add name="XmlSiteMapProvider"
            description="AugustSiteMap"
            type="System.Web.XmlSiteMapProvider "
            siteMapFile="AugustSiteMap.sitemap"
            securityTrimmingEnabled="true" />
        </providers>
      </siteMap>

How can I ensure that when the user is logged in, the appropriate menu items are displayed on the Landing page?

The problem being that, currently, a navigation menu is not created in any way, shape or form.

Please excuse my ignorance. Still new to all of this and my current method of 'trial and error' has seen me reach suicide levels this morning!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

木槿暧夏七纪年 2024-09-10 01:22:20

没关系 - 对于那些跟随者:这不是正确的答案。

尝试使用 DataSource 属性而不是 DataSourceId

例如

DataSource="AugustSiteMap"

Never mind - for those that follow: this is not the right answer.

Try using the DataSource property instead of DataSourceId.

e.g.

DataSource="AugustSiteMap"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文