In MVC5, I used to use 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 as System.Web
does not exist. What is the proper equivalent way of using session variables in the new framework? Documentation is still very scarce.
you need to install Nuget package
Microsoft.AspNet.Session
and use it using Context
Context.Session.SetString("Name", "My Name"); //Set
var name = Context.Session.GetString("Name");//Get
Good explanation can be found at http://www.mikesdotnetting.com/article/270/sessions-in-asp-net-5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With