.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值 获取值 |

浙公网安备 33010602011771号