An unhandled exception occurred while processing the request.
Microsoft.AspNetCore.Http.DefaultHttpContext.get_Session()
说明:Startup中未正确使用Session
解决:
安装Microsoft.AspNetCore.Session NuGet包
修改Startup.cs 添加相关服务,services.AddSession()和app.UseSession()【尤其注意,app.UseSession()必须要在app.UseMvc()之前】
Session 用法
引用
using Microsoft.AspNetCore.Http;
Session写入
HttpContext.Session.SetString("key", "value");
Session读取
HttpContext.Session.GetString("key");