.net core session的使用步骤

步骤

 操作

 备注

1  

Microsoft.AspNetCore.Session

Microsoft.AspNetCore.Http.Extensions

nuget安装包
2

ConfigureServices添加:  services.AddDistributedMemoryCache().AddSession(),

Configure添加:app.UseSession(); 

Startup.cs文件中,AddDistributedMemoryCache()必须要有,开启缓存
3 ConfigureServices中修改:options.CheckConsentNeeded = context => false;  //注意这里需要设置为false,默认为true  
4

HttpContext.Session.SetString("access_token", value);

HttpContext.Session.GetString("access_token");

设置session值   获取值
原文地址:https://www.cnblogs.com/zhuangjolon/p/11660100.html