我在sitemap中设置了roles="admin".
<?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="This is the home page" ImageURL="~/Images/homeimage.JPG" roles="admin"> <siteMapNode url="~/Products.aspx" title="Products" description="This is the products page" ImageURL="~/Images/productsimage.JPG"> <siteMapNode url="~/CDs.aspx" title="CDs" description="This is the CDs page" ImageURL="~/Images/productsimage.JPG" /> <siteMapNode url="~/DVDs.aspx" title="DVDs" description="This is the DVDs page" ImageURL="~/Images/productsimage.JPG" /> </siteMapNode> <siteMapNode url="~/Support.aspx" title="Support" description="This is the support page" ImageURL="~/Images/Supportimage.JPG" roles="admin" /> <siteMapNode url="~/Contact.aspx" title="Contact" description="This is the contact page" ImageURL="~/Images/Contactimage.JPG"> <siteMapNode url="~/ContactAddress/ContactAddress.aspx" title="Contact using physical address" description="This is the first contact page" ImageURL="~/Images/Contactphysicaladdressimage.JPG"/> <siteMapNode url="~/ContactEmailPhone/ContactEmailPhone.aspx" title="Contact by email or phone" description="This is the second contact page" ImageURL="~/Images/Contactphoneimage.JPG"/> </siteMapNode> </siteMapNode> </siteMap>
在master文件里面:
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="False" IncludeStyleBlock="False" Orientation="Horizontal" DataSourceID="SiteMapDataSource1"> </asp:Menu> <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" ShowLines="True"> </asp:TreeView> <asp:SiteMapPath ID="SiteMapPath1" runat="server" DataSourceID="SiteMapDataSource1"> </asp:SiteMapPath> <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
web.config文件里面:
<configuration> <connectionStrings> <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <authorization> <deny users="?" /> </authorization> <compilation debug="true" targetFramework="4.0" /> <authentication mode="Forms"> <forms loginUrl="~/Account/Login.aspx" timeout="2880" /> </authentication> <membership> <providers> <clear/> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> </providers> </membership> <profile> <providers> <clear/> <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/> </providers> </profile> <roleManager enabled="true"> <providers> <clear /> <add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" /> <!--<add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" />--> </providers> </roleManager> <urlMappings> <add url="~/CDs.aspx" mappedUrl="~/Products.aspx?ID=1"/> <add url="~/DVDs.aspx" mappedUrl="~/Products.aspx?ID=2"/> </urlMappings> <siteMap defaultProvider="XmlSiteMapProvider" enabled="true"> <providers> <add name="XmlSiteMapProvider" description="Default SiteMap provider." type="System.Web.XmlSiteMapProvider" siteMapFile="~/Web.sitemap" securityTrimmingEnabled="true"/> </providers> </siteMap> </system.web> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration>
为什么在访问default.aspx文件时候还是会显示support的菜单呢?