.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值   获取值
posted @ 2019-10-12 10:39  看不见的远方叫未来  阅读(414)  评论(0编辑  收藏  举报