Raj*_*oth 9 session asp.net-core asp.net-core-1.0 visual-studio-2017 asp.net-core-1.1
使用VS2017在ASP.Net Core 1.1中添加"AddSession"时出错.
'IServiceCollection'不包含'AddSession'的定义,并且没有扩展方法'AddSession'可以找到接受类型'IServiceCollection'的第一个参数(你是否缺少using指令或汇编引用?)
的.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>
Run Code Online (Sandbox Code Playgroud)
错误:
Lew*_*s86 11
我知道这有点晚了,但您是否尝试从nuget安装Microsoft.AspNetCore.Session包?
https://www.nuget.org/packages/Microsoft.AspNetCore.Session/
在Visual Studio中:安装包Microsoft.AspNetCore.Session -Version 1.1.2(在我的情况下)
它对我有用!
依赖项的版本似乎不同步。使用 Nuget 将所有软件包更新为相同版本,这应该可以解决问题。这适用于大多数(如果不是全部)Microsoft.* 软件包。
您还需要以下 using 语句:
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using System;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16689 次 |
| 最近记录: |