房产中介管理软件错误记录一

一、Core3.1添加Session后报错:Some services are not able to be constructed

在使用“services.AddSession();”和“app.UseSession();”之后,启动项目报错:

System.AggregateException:“Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Session.ISessionStore Lifetime: Transient ImplementationType: Microsoft.AspNetCore.Session.DistributedSessionStore': Unable to resolve service for type 'Microsoft.Extensions.Caching.Distributed.IDistributedCache' while attempting to activate 'Microsoft.AspNetCore.Session.DistributedSessionStore'.)”

解决办法:

新增:services.AddDistributedMemoryCache();

二、Core3.1添加Session后报错:Session has not been configured for this application or request.

明明已经添加了“services.AddSession();”和“app.UseSession();”,而且启动也不报错,

但是使用的时候报错:Session has not been configured for this application or request.

这个是因为中间件顺序加载有误

app.UseSession();需要放在“app.UseRouting();”和“app.UseEndpoints”中间

 

(本文持续更新中...)

 



 

posted @ 2022-09-22 09:20  RandyTech  阅读(420)  评论(0编辑  收藏  举报