Solved

How to fill site menu via Cache?

Posted on 2011-02-17
1
359 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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 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