Call Normal Method from Controller

Vote:
 

Hi,

I am using EPiServer CMS 10 hosted on Azure cloud. I am creating custom commerce site. I have created page for products. When user clicks on Add to cart button, I want to store the values in MVC session. I have written AddToSession method in the page controller. I want to access the controller method from razor view when user clicks on button. Below is my controller method:

public class ProductPageController : PageController
{

public ActionResult AddToSession(OrderDetails ordObj)
{
   if (Session["OrderDetails"] != null)
   {
      var ordSession = Session["OrderDetails"] as List;
       ordSession.Add(ordObj);
    }
   else
   {
      Session["OrderDetails"] = ordObj;
    }

return null;
}

}

View:

@Html.Action("AddToSession", "ProductPage", new OrderDetails { ProductId=100, Qty=2 });

How can I do this?

//Sanket Mahimkar

#180454
Jul 11, 2017 12:02
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.