“ IServiceCollection”不包含“ AddSession”的定义 [英] 'IServiceCollection' does not contain a definition for 'AddSession'
本文介绍了“ IServiceCollection”不包含“ AddSession”的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用VS2017在ASP.Net Core 1.1中添加'AddSession'时出现错误。
I am getting an error while adding 'AddSession' in ASP.Net Core 1.1 using VS2017.
'IServiceCollection'不包含找不到'AddSession'
的定义,并且找不到扩展方法'AddSession'接受
类型'IServiceCollection'的第一个参数(是否缺少使用
指令或程序集引用?)
'IServiceCollection' does not contain a definition for 'AddSession' and no extension method 'AddSession' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive 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>
错误:
推荐答案
以下是我修复问题的方法。
The following way I fixed the Issue.
- 清洁并重建解决方案。
- 重新启动Visual Studio 2017。
感谢@HenkMollema
Thanks @HenkMollema
这篇关于“ IServiceCollection”不包含“ AddSession”的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文