mercredi 6 janvier 2016

invoke a session inside a method where that session create

I'm trying to reuse a session inside a method where that session created.

    public ActionResult Add_Product(AddNewProduct sample)
    {
        //create the session
        TempData["AddNewProduct"] = sample;

        //create the object of AddNewProduct and invoking the session
        AddNewProduct book = TempData["AddNewProduct"] as AddNewProduct;

        AddNewProduct model = new AddNewProduct();

        model.FirstName = "XXX";

        sample = model;

        return View(model);

    }

In this view page I have button to call to this Action again, once I click and debug the code I can see session getting null

Aucun commentaire:

Enregistrer un commentaire