Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1014495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:15:41+00:00 2026-05-16T10:15:41+00:00

My asp.net application has a function that returns the HTML for the navigation menu

  • 0

My asp.net application has a function that returns the HTML for the navigation menu for the user by getting it from a database

currently, I am storing the text in a session variable when the session begins and then use it to set the innerHtml of the navigation div on the on_load method.

The problem is that the pages now contain the

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPD..

with the value being 7000 characters long.

Is there any better way to do this or a different way to store and retrieve values without them being stored in the viewstate ?

The code is just this:

Session["menuHTML"] = (new NavMenu().GetMenuHTML());
navMenuDiv.InnerHtml = Session["menuHTML"].ToString();

The div is declared as

<div id="navMenuDiv" class="navMenuDiv" runat="server"></div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:15:42+00:00Added an answer on May 16, 2026 at 10:15 am

    I would cache the data returned from your database call and then generate the navigation html for each page as it’s the db call that is the bit you don’t want to be doing over and over.

    To cache the data I’d do something like this (have not tried it):

    public NavData GetNavData()
    {
        NavData navdata = Cache["NavData"];
        if (navdata == null)
        {
            navdata = SomeDataStore.GetNavDataFromDatabase();
            Cache["NavData"] = navdata;
        }
        return navdata;
    }
    

    In answer to your question though, and without being rude, are you sure you’re putting it in Session and not ViewState?

    EDIT: Because you have turned that div into a server control, it’s storing it’s value in ViewState.

    Switch ViewState off for navMenuDiv:

    navMenuDiv.EnableViewState = false;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET MVC application that has one part where I dont really
I am creating an ASP.NET MVC application that has postcode lookup functionality. I capture
My client has a asp.net application, using ajax, he has a datagrid that shows
I have an ASP.NET MVC3 application that I have built and it has two
In my ASP.NET MVC application, I'm trying to figure out whether the user has
I am working on maintaining a ASP.NET MVC application that has the following coding
We currently have an existing ASP.NET application that we want to migrate to DNN.
I am calling an ASP.net application that has an exposed JSON web service interface.
I was in a ASP.NET application has heavy traffic of AJAX requests. Once a
I have a ASP.NET web application which has more than 100 pages. Each page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.