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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:04:06+00:00 2026-06-17T11:04:06+00:00

I have a Shopping Basket which holds selected items by the user and is

  • 0

I have a Shopping Basket which holds selected items by the user and is stored in a session variable. I’d like this to show various values on every view about the basket state i.e. basket:1, but I can only see how to pass this to a view at a single entry point. How would I initialise every view with this List?

  • 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-17T11:04:06+00:00Added an answer on June 17, 2026 at 11:04 am

    You could render a child action in your Layout. The idea of a child action is that it could execute some logic in parallel to the main action.

    For example you could have the following controller:

    public class ShoppingBasketInfoController: Controller
    {
        [ChildActionOnly]
        public ActionResult Index()
        {
            var model = Session["info"] as ShoppingInfoViewModel;
            return PartialView(model);
        }
    }
    

    and then you will have a corresponding partial view (~/Views/ShoppingBasketInfo/Index.cshtml):

    @model ShoppingInfoViewModel
    <div>
        You have @Html.DisplayFor(x => x.NbProducts) in your basket
    </div>
    

    and then you could find an appropriate place in your Layout to render this action:

    @Html.Action("Index", "ShoppingBasketInfo")
    

    Now all your views will have this information shown at the specified location without worrying about where this information is coming from, how is it stored or what view model it uses. The main actions are completely independent.

    I have decorated the child action with the [ChildActionOnly] attribute to ensure that this action will never be accessible through a normal HTTP request from the client using for example /ShoppingBasketInfo/Index. It could only be used within the context of the main executing action.

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

Sidebar

Related Questions

I have set up a shopping basket which is a session list is stored
I have a repeater, which represents a shoppingbasket. This shopping basket has an Update
I have a table which holds the products in a shopping basket (stowaway_orders) and
I have the following code which is used to slidein/out a div (shopping basket)
Here's the problem: A user has a shopping basket containing items, where each item
i have a javascript shopping basket, in which the sum is returning a NaN
I have my own basket which is built up based on what the user
I have the following assignment: Implement a basic shopping basket without using any predefined
Hi i'm creating an app which have shopping cart and payment done via paypal
I have a online shopping cart, at checkout user enters his zipcode. There are

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.