Hi,
Good Morning.
I used site map with role based authentication. When pass role value the menu will not be displaying.
but, when i hard code the particular role then it will work.
Working code
Dim arr As String() = {"Stu"}
HttpContext.Current.User = New GenericPrincipal(HttpContext.Current.User.Identity, arr)
menu will be appearing perfect.
Not working code
Dim arr As String() = {Session("Stu")}
HttpContext.Current.User = New GenericPrincipal(HttpContext.Current.User.Identity, arr)
Session value will be passing but, menu will not appear.
below is my code
<location path="Administrator">
<system.web>
<authorization>
<allow roles="Adm"/>
<deny users="*" />
</authorization>
</system.web>
</location>
<location path="Student">
<system.web>
<authorization>
<allow roles="Adm,Stu"/>
<deny users="*" />
</authorization>
</system.web>
</location>
<location path="Home">
<system.web>
<authorization>
<allow roles="Adm,Stu,oth"/>
<deny users="*" />
</authorization>
</system.web>
</location>
Site.map
="1.0"="utf-8"
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="Home" description="" roles="Adm,Stu,Oth">
<siteMapNode url="Home.aspx" title="Home" description="Home Page" roles="Adm,Stu,Oth"></siteMapNode>
<siteMapNode url="javascript:;" title="Administrator" description="Administrator" roles="Adm">
<siteMapNode url ="Admin_page1.aspx" title="Admin1" description="Admin1" roles="Adm"></siteMapNode>
<siteMapNode url ="Admin_page2.aspx" title="Admin2" description="Admin2" roles="Adm"></siteMapNode>
</siteMapNode>
<siteMapNode url="javascript1:;" title="Student" description="Student" roles="Adm,Stu">
<siteMapNode url ="Student_Page1.aspx" title="StudentPage1" description="StudentPage1" roles="Adm,Stu"></siteMapNode>
<siteMapNode url ="Student_Page2.aspx" title="StudentPage2" description="StudentPage2" roles="Adm,Stu"></siteMapNode>
<siteMapNode url ="Student_Page3.aspx" title="StudentPage3" description="StudentPage3" roles="Adm,Stu"></siteMapNode>
</siteMapNode>
<siteMapNode url ="Lesson.aspx" title="Lesson" description="Lesson" roles="Adm,Stu,Oth"></siteMapNode>
<siteMapNode title="Users" description="Users" roles="Adm,Stu,Oth"></siteMapNode>
<siteMapNode title="Contact" description="Contact" roles="Adm,Stu,Oth"></siteMapNode>
</siteMapNode>
</siteMap>
i am struggling the above code to get the menu for particular role based...
This most important in my project.
pls. help
What I have tried:
Working code
Dim arr As String() = {"Stu"}
HttpContext.Current.User = New GenericPrincipal(HttpContext.Current.User.Identity, arr)
menu will be appearing perfect.
Not working code
Dim arr As String() = {Session("Stu")}
HttpContext.Current.User = New GenericPrincipal(HttpContext.Current.User.Identity, arr)
Session value will be passing but, menu will not appear.
below is my code
<location path="Administrator">
<system.web>
<authorization>
<allow roles="Adm" />
<deny users="*" />
</authorization>
</system.web>
</location>
<location path="Student">
<system.web>
<authorization>
<allow roles="Adm,Stu" />
<deny users="*" />
</authorization>
</system.web>
</location>
<location path="Home">
<system.web>
<authorization>
<allow roles="Adm,Stu,oth" />
<deny users="*" />
</authorization>
</system.web>
</location>
Site.map
<sitemap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<sitemapnode url="" title="Home" description="" roles="Adm,Stu,Oth">
<sitemapnode url="Home.aspx" title="Home" description="Home Page" roles="Adm,Stu,Oth"></sitemapnode>
<sitemapnode url="javascript:;" title="Administrator" description="Administrator" roles="Adm">
<sitemapnode url="Admin_page1.aspx" title="Admin1" description="Admin1" roles="Adm"></sitemapnode>
<sitemapnode url="Admin_page2.aspx" title="Admin2" description="Admin2" roles="Adm"></sitemapnode>
</sitemapnode>
<sitemapnode url="javascript1:;" title="Student" description="Student" roles="Adm,Stu">
<sitemapnode url="Student_Page1.aspx" title="StudentPage1" description="StudentPage1" roles="Adm,Stu"></sitemapnode>
<sitemapnode url="Student_Page2.aspx" title="StudentPage2" description="StudentPage2" roles="Adm,Stu"></sitemapnode>
<sitemapnode url="Student_Page3.aspx" title="StudentPage3" description="StudentPage3" roles="Adm,Stu"></sitemapnode>
</sitemapnode>
<sitemapnode url="Lesson.aspx" title="Lesson" description="Lesson" roles="Adm,Stu,Oth"></sitemapnode>
<sitemapnode title="Users" description="Users" roles="Adm,Stu,Oth"></sitemapnode>
<sitemapnode title="Contact" description="Contact" roles="Adm,Stu,Oth"></sitemapnode>
</sitemapnode>
</sitemap>