Solved

How to fill site menu via Cache?

Posted on 2011-02-17
1
355 Views
Last Modified: 2013-12-17
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
Comment
Question by:programmerist
1 Comment
 
LVL 18

Accepted Solution

by:
Richard Lee earned 500 total points
ID: 34941769
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question