Asp.net core中使用Session

添加Session Nuget包

更新Startup.cs文件

在ConfigureServices方法中添加如下代码
services.AddSession(options =>
{
// Set a short timeout for easy testing.
options.IdleTimeout = TimeSpan.FromSeconds(3);
options.CookieHttpOnly = true;
});
在Configure方法中添加如下代码

        app.UseSession();

使用Session

posted @ 2017-04-25 13:49  JiaLiWei  阅读(1373)  评论(0编辑  收藏  举报