Click here to Skip to main content
14,881,545 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i write program using asp.net empty website c#,i created menu with site map data source
the code in mapsite:
XML
<siteMapNode url="Home.aspx"  title="Home"  description="" roles="*"  >
    <siteMapNode url="" title="Master"  description=""  roles="homas,admin" >
      <siteMapNode url="" title="Medical Treating Agency"  description="" roles="homas,admin">
        <siteMapNode url="~\Master\MAT\Add.aspx" title="Add"  description=""  roles="homas,admin"/>
        <siteMapNode url="~\Master\MAT\Modify.aspx" title="Modify"  description=""  roles="homas,admin"/>
        <siteMapNode url="~\Master\MAT\Delete.aspx" title="Delete"  description=""  roles="homas,admin"/>
      </siteMapNode>
      <siteMapNode url="" title="Category"  description="" roles="admin">
        <siteMapNode url="Master/CAT/Add.aspx" title="Add"  description=""  roles="admin"/>
        <siteMapNode url="Master/CAT/Modify.aspx" title="Modify"  description=""  roles="admin"/>
        <siteMapNode url="Master/CAT/Delete.aspx" title="Delete"  description=""  roles="admin"/>
      </siteMapNode>
    </siteMapNode>
 </siteMapNode>


in web.config:
XML
<siteMap>
      <providers>
        <add name="MainWebSitemap" type="System.Web.XmlSiteMapProvider" siteMapFile="Web.sitemap" securityTrimmingEnabled="true"/>
      </providers>
    </siteMap>

    <authentication mode="Forms">
      <forms loginUrl="~/Login.aspx" protection="All" timeout="2880" defaultUrl="~/Login.aspx"/>
    </authentication>

    <authorization>
      <deny users="?"/>
    </authorization>


  </system.web>

    <location path="Master/MAT/Add.aspx">
    <system.web>
      <authorization>
        <allow roles="homas,admin" />
        <deny users="?"/>
      </authorization>
    </system.web>
  </location>

   <location path="Master/MAT/Modify.aspx">
    <system.web>
      <authorization>
        <allow roles="homas,admin" />
        <deny users="?"/>
      </authorization>
    </system.web>
  </location>

  <location path="Master/MAT/Delete.aspx">
    <system.web>
      <authorization>
        <allow roles="homas,admin" />
        <deny users="?" />
      </authorization>
    </system.web>
  </location>


i have login page and sql database for users. in login page i check if the user available and i write this:
FormsAuthentication.RedirectFromLoginPage(username.Text, true);

then i send the username to the master page
and i writ this code in the master page:
C#
protected void Page_Load(object sender, EventArgs e)
    {
        string field1 = (string)(Session["field1"]);

        string[] r = { field1 };

        HttpContext.Current.User = new GenericPrincipal(HttpContext.Current.User.Identity, r);
    }


now when access as guest menus should be disable ,when access as homas the category menu should be disable,for admin all menus should be enable.
now my code not work ,any idea please?
Posted
Updated 8-Nov-15 21:57pm
v8
Comments
loai_maane 9-Nov-15 6:39am
   
please any idea!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900