您好,可以这样来试一下在custom api 工程(.net Standard2.0 )加如下的cs 文件,另外需要添加Nuget 引用 Microsoft.AspNetCore.Session
public class SessionMiddlewareInjector : MiddlewareInjector
{
public override List<ServiceItem> ConfigureServices(List<ServiceItem> serviceItems, IServiceCollection services)
{
serviceItems.Add(new ServiceItem("25A1A4B7-1E1E-4417-A8EF-336E04E304AC", "AddSession")
{
ConfigureServiceAction = () => { services.AddSession(options => { options.Cookie.IsEssential = true; }); }
});
return serviceItems;
}
public override List<MiddlewareItem> Configure(List<MiddlewareItem> middlewareItems, IApplicationBuilder app)
{
middlewareItems.Add(new MiddlewareItem("25A1A4B7-1E1E-4417-A8EF-336E04E304AC", "AddSession")
{
ConfigureMiddleWareAction = () => { app.UseSession(); }
});
return middlewareItems;
}
}
|