Link to home
Start Free TrialLog in
Avatar of programmerist 1983
programmerist 1983Flag for Türkiye

asked on

How to fill site menu via Cache?

i try to fill my menu with company stuff roles. Filling site map needs to many time.(4000ms) however; i filled site menu only one time in loading menu. like that:
NOT necessary to fill menu via cache . you can give me another advise to do it:)
    protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                if (Session["IsPostBack"] == null)
                {
                    FillMenu();
                }
                else
                {

                    SiteMapProvider sitemapProvider = (SiteMapProvider)Cache.Get("menu");
                    ASPxSiteMapDataSource1.Dispose();
                    ASPxSiteMapDataSource1.Provider = sitemapProvider;
                    ASPxSiteMapDataSource1.DataBind();
                    ASPxMenuMain.Dispose();
                    ASPxMenuMain.DataSource = ASPxSiteMapDataSource1;
                    ASPxMenuMain.DataBind();
                }
  protected void FillMenu()
        {
                SiteMapProvider sitemapProvider = GetSiteMapProvider(tempx);
                ASPxSiteMapDataSource1.Provider = sitemapProvider;
                ASPxSiteMapDataSource1.DataBind();
                ASPxMenuMain.DataSource = ASPxSiteMapDataSource1;
                ASPxMenuMain.DataBind();
                FillFromCache(sitemapProvider);
                Session["IsPostBack"] = "Postback";

        }
    protected void FillFromCache(SiteMapProvider _provider)
        {
            if (Cache["menu"] == null)
            {
                Cache.Insert("menu", _provider);
            }
        }

Open in new window

Everything is ok on my local pc. After publishing my asp.net project, i see that our portal's menu don't show correct menu element.How can i solve it?
ASKER CERTIFIED SOLUTION
Avatar of Avodah
Avodah
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial