You must Sign In to post a response.
  • Category: .NET

    How to get values in MVC

    Hi MVC

    How to get Value from One method to another method present in same controller

    like session
    but session not working here

    i tried like this

    ViewData["OrderId"] = OrderId;
    ViewBag.OrderId = OrderId;
    TempData["OrderId"] = OrderId;
  • #770012

    Did you tried of using TempData, To pass some data from one action method to another while redirecting the user to another action method.

    public ActionResult ControllerMethod1()
    TempData.Add("OrderId", OrderId);
    return RedirectToAction("ControllerMethod2"); // Below action method will be called

    public ActionResult ControllerMethod2()
    return Content(TempData["OrderId"].ToString());

    Hope this will help you.

    Never lose hope..You never know what tomorrow will bring

  • #770013
    I am using your code also not working. when i postback all the values cleared.

    Name : Dotnet Developer-2015
    Email Id :

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • Sign In to post your comments