InvalidOperationException: Session has not been configured for this application or request.

时间:2024-03-21 14:14:16

asp.net3.1 core使用Session报错InvalidOperationException: Session has not been configured for this application or request.

解决方案:
找到StartUp类
第一步:在ConfigureServices方法中添加一个services.AddSession();
InvalidOperationException: Session has not been configured for this application or request.
第二步使用Session
在Configure方法中添加 app.UseSession();方法
InvalidOperationException: Session has not been configured for this application or request.