Menu Role configuration
Code .NET SQL :: ASP.NET :: C# :: Navigation
Page 1 sur 1
Menu Role configuration
Creer Roles :
Global.asax.cs
Web.Config
Web.Sitemap
MasterPage
Localization du .SiteMap
Global.asax.cs
- Code:
protected void Application_Start(Object sender, EventArgs e)
{
if (!Roles.RoleExists(RolesDefinition.BASIC))
Roles.CreateRole(RolesDefinition.BASIC);
if (!Roles.RoleExists(RolesDefinition.SUPERADMIN))
{
Roles.CreateRole(RolesDefinition.SUPERADMIN);
Roles.AddUserToRole("FR-Corp\\MOI", "SuperAdmin");
}
}
Web.Config
- Code:
<siteMap defaultProvider="XmlSiteMapProvider" enabled="true" >
<providers>
<add name="XmlSiteMapProvider" description="Configuration du Menu principal" type="System.Web.XmlSiteMapProvider" securityTrimmingEnabled="true" siteMapFile="Web.sitemap"/>
</providers>
</siteMap>
- Code:
<!-- ==================================================================================
CONFIGURATION ROLEMANAGER
================================================================================== -->
<roleManager enabled="true" cacheRolesInCookie="false" defaultProvider="RoleManagerSqlProvider">
<providers>
<add name="RoleManagerSqlProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="SQLConnectionString" applicationName="AppName"/>
</providers>
</roleManager>
- Code:
<location path="ChapterManagement">
<system.web>
<authorization>
<allow roles="Basic"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
<location path="Administration/ManageUser.aspx">
<system.web>
<authorization>
<allow roles="SuperAdmin"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
Web.Sitemap
- Code:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap>
<siteMapNode roles="*">
<siteMapNode title="My Settings" roles="Basic" imageUrl="~/Resources/Images/Icons/Parametrage.gif"></siteMapNode>
<siteMapNode title="Administration" roles="*" imageUrl="~/Resources/Images/Icons/Etats.gif" description="Etats">
<siteMapNode title="Manage Users" roles="SuperAdmin" url="~/Administration/ManageUser.aspx" description="descr"/>
</siteMapNode>
</siteMapNode>
</siteMap>
MasterPage
- Code:
<asp:Menu ID="Menu1" runat="server" BackColor="#B5C7DE" DataSourceID="SiteMapDataSourceDefault"
DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284E98"
Orientation="Horizontal" StaticSubMenuIndent="10px" Width="600px">
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicHoverStyle BackColor="#284E98" ForeColor="White" />
<DynamicMenuStyle BackColor="#B5C7DE" />
<StaticSelectedStyle BackColor="#507CD1" />
<DynamicSelectedStyle BackColor="#507CD1" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticHoverStyle BackColor="#284E98" ForeColor="White" />
</asp:Menu>
<asp:SiteMapDataSource ID="SiteMapDataSourceDefault" runat="server" ShowStartingNode="false"
SiteMapProvider="XmlSiteMapProvider" />
Localization du .SiteMap
- Code:
<siteMap enableLocalization="true" xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Default.aspx" title="Home" description="Home">
<siteMapNode url="" title="$resources:MenuStrings,SPECIFIC_ADMINISTRATION" description="$resources:MenuStrings,SPECIFIC_ADMINISTRATION">
Code .NET SQL :: ASP.NET :: C# :: Navigation
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum