Below is the code in JAVA written inside a controller. I am saving the cart object inside the HttpSession, so that I can retrieve it always for the same session. Is there any way to do a similar thing in C#?
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("in servlet");
Cart cart = getCartFromSession(request);
}
Cart getCartFromSession(HttpServletRequest req){
HttpSession session = req.getSession(true);
Cart cart=(Cart)session.getAttribute("cart");
if(cart==null){
cart = new Cart();
session.setAttribute("cart", cart);
}
return cart;
}