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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:36:42+00:00 2026-06-15T00:36:42+00:00

got a tricky one here me thinks! I want to understand how if this

  • 0

got a tricky one here me thinks!

I want to understand how if this Cart object gets passed by value using the model binder, then how can it effect the actual value in the session?

  public RedirectToRouteResult AddToCart(Cart cart, int productId, string returnUrl) {
        Product product = repository.Products
            .FirstOrDefault(p => p.ProductID == productId);

        if (product != null) {
            cart.AddItem(product, 1);
        }
        return RedirectToAction("Index", new { returnUrl });
    }

Hope this explains my issue!

Thanks for any assistance

details

this bold code doesn’t effect the customprofile in session

   [AllowAnonymous]
    [HttpPost]
    public ActionResult Register(RegisterModel model, CustomProfile customProfile)
    {
        if (User.Identity.IsAuthenticated)
            return RedirectToAction("Index", "Home");
        if (ModelState.IsValid)
        {
            // Attempt to register the user
            MembershipCreateStatus createStatus;


            membershipProvider.CreateUser(model, null, null, true, null,
                                          out createStatus);

            if (createStatus == MembershipCreateStatus.Success)
            {
                const string message = "You have successfully reigestered, and you are now logged in.";
                authProvider.SetAuthCookie(model.UserName, false /* createPersistentCookie */);

                var newCustomProfile = new CustomProfile(model.UserName);
                var db = new CrowdFundingDB();

                **customProfile = customProfileProvider.Create(newCustomProfile);**
  • 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-15T00:36:43+00:00Added an answer on June 15, 2026 at 12:36 am

    Cart is not a value type, it’s a reference type.

    Passing it as an argument doesn’t make a copy of the object, the method receives a copy of the reference to the actual object. It will access the same object through the copied reference.

    See also: ByRef vs ByVal Clarification

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

Sidebar

Related Questions

Ok, got a tricky one here... If my data looks like this: Table1 ID
Got this error message while trying to load view: The model item passed into
I've got a bit of a tricky one here, 3 tables as follows in
My first query where I got problem here : Tricky GROUP BY issue on
Almost the same question as this one here: What's the easiest way to grab
I've got a rather tricky one, bear with me as I try not to
I've got following code to perform XSLT transformation from one JAXB annotated object to
We've got into a very tricky scenario in a project. We have used lot
I've got kind of a tricky question, I already searched every related question on
Got a programm with 2 threads. one thread is writing some stuff into the

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.