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 7827405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:51:36+00:00 2026-06-02T09:51:36+00:00

I have a problem with a ViewBag function pointer value being lost during a

  • 0

I have a problem with a ViewBag function pointer value being lost during a PostBack.

My site has a banner ( partial view ) where I indicate my customer’s status by utilizing a ViewBag function pointer:

ViewBag.CustomerStatus= new Func<id, string>(GetCustomerStatus);

(Where id is my customer’s id and returned string it’s returned status )

As I start going to other pages that utilize the banner partial view I loose my CustomerStatus ViewBag variable. I know ViewBags are only available “per page” but how can I make my Customer status function available from other places in the application without being redundant and repeating ViewBag.CustomerStatus= new Func(GetCustomerStatus); on every single ActionMethod call ?

Is it possible to have a function pointer stored in Session/ViewState? Safe ?
How can I access my up to date customer status across postbacks ?

Thank you in advance.

  • 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-06-02T09:51:38+00:00Added an answer on June 2, 2026 at 9:51 am

    I ended up taking the following approach…

    Instead of rendering partial view directly I changed it up so it’s called through an Action method of the controller.

    I created:

     public PartialViewResult CustomerStatus()
     {
      ...here I called my private GetCustomerStatus methods
      ViewBag.CustomerStatus = GetCustomerStatus();
      Return PartialView("
     }
    

    So now instead of calling a ViewBag function pointer separately, whenever the header banner has to be rendered, instead of @Html.Partial(“BannerPartialView”) I call my @Html.Action(CustomerStatus) method that returns that same banner but with the customer status variable available.

    Hope it’s not to confusing and helps to someone else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive got a mega annoying problem I have a view with: @{ if(ViewBag.Section ==
I have problem with fancybox. I want to write a function that will run
I have problem with cakephp's Session->write method. If I set a value like $_SESSION['..']
MVC 3 VB.NET razor. I have a view that has 4 dropdown boxes in
I have a strange problem with my model passed to the View Controller [Authorize]
I have problem in my split Sentence function . The idea of ​​my function
in views/jump/index have problem. first rows: @model IEnumerable<WhislaMvc.Areas.Admin.Models.Jump> @{ ViewBag.Title = Index; } @model
Hi I have problem with my html helper extension method in razor view engine.
The purpose I have a simple table listing names (in a partial view), and
i have problem to pass data from view to controller , i have view

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.