Session Variables in ASP5 / MVC6

In MVC5, I used my session variables, like this from System.Web

PayPalHandler.ExecutePayment( Convert.ToString(Session["paymentId"]), Convert.ToString(Session["payerId"])); 

In ASP5 / MVC6, this is no longer an option, since System.Web does not exist. What is the correct equivalent way to use session variables in a new structure? The documentation is still very scarce.

+6
source share
1 answer

you need to install the nuget package

 Microsoft.AspNet.Session 

and use it with context

 Context.Session.SetString("Name", "My Name"); //Set var name = Context.Session.GetString("Name");//Get 

A good explanation can be found at http://www.mikesdotnetting.com/article/270/sessions-in-asp-net-5

+3
source

Source: https://habr.com/ru/post/989559/


All Articles