gpt4 book ai didi

session - “IServiceCollection”不包含 'AddSession' 的定义

转载 作者:行者123 更新时间:2023-12-04 02:36:44 26 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Trying to add AutoMapper to .NetCore1.1 - not recognising services.AddAutoMapper()

(10 个回答)


12 个月前关闭。




使用 VS2017 在 ASP.Net Core 1.1 中添加“AddSession”时出现错误。

'IServiceCollection' does not contain a definition for 'AddSession'and no extension method 'AddSession' accepting a first argument oftype 'IServiceCollection' could be found (are you missing a usingdirective or an assembly reference?)


.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Session" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference
Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>

</Project>
错误:
enter image description here

最佳答案

我知道这有点晚了,但是您是否尝试从 nuget 安装 Microsoft.AspNetCore.Session 包?

https://www.nuget.org/packages/Microsoft.AspNetCore.Session/

在 Visual Studio 中:
安装包 Microsoft.AspNetCore.Session -Version 1.1.2(在我的情况下)

它对我有用!

关于session - “IServiceCollection”不包含 'AddSession' 的定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44409554/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com