使用web.sitemap

时间:2019-05-20 08:06:49

标签: .net xml webforms web-config web.sitemap

我在客户网站上创建一个下拉菜单,此菜单由角色(成员身份),某些文件夹上的web.config授权和站点地图控制。当以“客户”角色身份登录时,下拉菜单为空,根本没有节点。以管理员身份登录时,仅显示菜单的admin部分,而不显示每个人都可以访问的节点。

试图对节点应用不同的角色。删除/向节点添加URL。检查角色是否以某种方式在sql数据库中被删除。

站点地图:

<?xml version="1.0" encoding="utf-8" ?>
  <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"      enableLocalization="true">
  <siteMapNode url="start" roles="*">    
    <siteMapNode url="#" title="Kundecenter" >
      <siteMapNode url="~/xCustomer/Info.aspx" resourceKey="YourOrders" roles="*">
        <siteMapNode url="~/xCustomer/SalesOrders.aspx" resourceKey="CustomerSalesOrders"/>       
      </siteMapNode>     
      <siteMapNode url="~/xCustomerService/Internal/CustomerList.aspx" resourceKey="CustomerList" roles="Intern,Administrator"/>      
      <siteMapNode url="~/xAdministration/Default.aspx" resourceKey="Administration">
        <siteMapNode url="~/xAdministration/Users/Default.aspx" resourceKey="AdministrationUsers">
          <siteMapNode url="~/xAdministration/Users/AddUser.aspx" resourceKey="AdministrationUsersAddUser"/>
        </siteMapNode>
        <siteMapNode url="~/xAdministration/Basket/Default.aspx" resourceKey="AdministrationBaskets"/>       
        <siteMapNode url="~/xAdministration/xCMS/Default.aspx" resourceKey="CMS">
          <siteMapNode url="~/xAdministration/xCMS/EditCMS.aspx" resourceKey="AdministrationCMS_New"/>
        </siteMapNode>       
        <siteMapNode url="~/xAdministration/xNewsletter/Default.aspx" resourceKey="NewsletterAdmin">
          <siteMapNode url="~/xAdministration/xNewsletter/Groups.aspx" resourceKey="NewsletterAdminGroups"/>         
        </siteMapNode>
        <siteMapNode url="~/xAdministration/xReports/Default.aspx" resourceKey="Administration_Reports"/>
        <siteMapNode url="~/xAdministration/xProductCatalogue/Default.aspx" resourceKey="AdministrationProductCatalogue">
          <siteMapNode url="~/xAdministration/xProductCatalogue/setup.aspx?Page=Products" resourceKey="AdministrationProductCatalogue_Items"/>          
        </siteMapNode>
        <siteMapNode url="~/xAdministration/Logs/Default.aspx" resourceKey="Administration_Logs">
          <siteMapNode url="~/xAdministration/Logs/Log.aspx" resourceKey="Administration_Logs_ErrorLog"/>         
        </siteMapNode>
        <siteMapNode url="~/xAdministration/xProject/Default.aspx" resourceKey="Administration_Project" >
          <siteMapNode url="~/xAdministration/xProject/Employee.aspx" resourceKey="Administration_Project_Employee" />         
        </siteMapNode>
        <siteMapNode url="~/xCustomerService/xBudget/" resourceKey="CustomerService_Budget" />
      </siteMapNode>
      <siteMapNode url="~/xCustomerService/SalesRep/CustomerList.aspx" resourceKey="CustomerList">
        <siteMapNode url="~/xCustomerService/SalesRep/Quotations.aspx" resourceKey="CustomerServiceQuotations"/>       
      </siteMapNode>
      <siteMapNode url="~/xVendor/Info.aspx" resourceKey="Vendor">
        <siteMapNode url="~/xVendor/Internal/" resourceKey="Vendors"/>       
      </siteMapNode>
      <siteMapNode url="~/xReports/Default.aspx" resourceKey="Reports" />     
    </siteMapNode>
  </siteMapNode>
</siteMap>

ASPX:

<figure class="CustomerCenterFig col-sm-2 pull-right-sm">
     <asp:HyperLink ID="CustomerCenter_Link" runat="server" NavigateUrl="~/" EnableViewState="False" CssClass="Booking_Link">                           
            <asp:image CssClass="bookingImg" imageurl="~/App_Themes/Default/Images/login.png" runat="server" />                      
     </asp:HyperLink>
     <figcaption>                                
            <uc:BootstrapMenu ID="MainMenu" runat="server" DataSourceID="SiteMapMain_DS" MaximumDynamicDisplayLevels="3" CssClass="dropdown">
            </uc:BootstrapMenu>
            <asp:SiteMapDataSource ID="SiteMapMain_DS" SiteMapProvider="XmlSiteMapProvider"
                                runat="server" ShowStartingNode="false" StartingNodeUrl="start" />
     </figcaption>
</figure>

管理员角色应该能够看到所有菜单节点。客户角色只能看到该节点内部的内容

<siteMapNode url="~/xCustomer/Info.aspx" resourceKey="YourOrders" roles="*">

0 个答案:

没有答案