Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 380
  • Last Modified:

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?
0
programmerist
Asked:
programmerist
1 Solution
 
Richard LeeSoftware EnthusiastCommented:
Put the menu in a usercontrol and use outputcache to have the menu either cached by IIS server side or cache by the client and along the route.

http://support.microsoft.com/kb/308375

DaTribe
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Tackle projects and never again get stuck behind a technical roadblock.
Join Now