IApplicationBuilder UseCookieAuthentication扩展方法在哪里?

时间:2016-03-07 23:31:08

标签: visual-studio-2015 dnx

我下载了一个私人git项目,其他开发人员已经开展了几个月的工作。在构建项目时,我遇到了一些问题:

  • 要最初恢复软件包,我需要从命令行执行dnu restore。在Visual Studio 2015中,包恢复似乎在此之后正常工作。
  • 一个项目在.cs文件中仍然有一些缺少的引用。我通过将包添加到相应的project.json文件来修复它。

现在我只剩下一个错误: IApplicationBuilder does not contain a definition for 'UseCookieAuthentication ...

代码需要一个匿名函数:

app.UseCookieAuthentication(options =>
{
    options.AuthenticationScheme = "NLCookieMiddleware";
    options.LoginPath = new PathString("/api/Account/Login/");
    //options.AccessDeniedPath = new PathString("/Account/Forbidden/");
    options.AutomaticAuthenticate = true;
    options.AutomaticChallenge = true;
});

令我感到困惑的是,其他开发人员构建很好,没有添加任何其他对他们的project.json文件的引用。他们的工作文件是:

{
  "webroot": "wwwroot",
  "version": "1.0.0-*",
  "dependencies": {
    "AutoMapper": "3.3.1",
    "Core": "1.0.0-*",
    "Data.EF": "1.0.0-*",
    "FluentMigrator": "1.6.0",
    "HtmlAgilityPack": "1.4.9",
    "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
    "Microsoft.AspNet.Hosting": "1.0.0-rc1-final",
    "Microsoft.AspNet.Identity": "3.0.0-rc1-final",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
    "Microsoft.AspNet.Identity.Owin": "1.0.0-rc1",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.Core": "6.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Abstractions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration": "1.0.0-rc1-final",
    "WindowsAzure.Storage": "5.0.0",
    "System.Net.Http": "4.0.0",
    "RazorEngine": "4.2.3-beta1",
    "Microsoft.AspNet.Razor": "4.0.0-rc1-final",
    "premailer.net": "1.4.2",
    "Microsoft.Net.Http.Client": "1.0.0-beta6",
    "Moq": "4.2.1510.2205",
    "Serilog.Framework.Logging": "1.0.0-rc1-final-10071",
    "Microsoft.AspNet.WebApi.Client": "5.2.3",
    "Microsoft.Net.Http.Server": "1.0.0-rc1-final",
    "StructureMap.Dnx": "0.4.0-alpha4"
  },
  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"
  },
  "frameworks": {
    "dnx451": {
      "dependencies": {
        "CMS.Services.Contracts": "1.0.0-*",
        "CSharpSDK": "1.0.0-*",
        "Lookups.Contracts": "1.0.0-*",
        "Services.Internal.Contracts": "1.0.0-*"
      },
      "frameworkAssemblies": {
        "System.ServiceModel": "4.0.0.0",
        "System.DirectoryServices.AccountManagement": "4.0.0.0"
      }
    }
  },
  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ]
}

我添加了无数其他软件包并尝试了旧版本但没有运气:

  • Microsoft.AspNet.Authentication.Cookies
  • Microsoft.Owin.Security.Cookies.Interop

这种扩展方法在哪里?为什么其他开发人员不会遇到这个问题?

1 个答案:

答案 0 :(得分:2)

这可能就是你要找的东西。请注意,这包含其他所需的升级/新库。对不起,这可能非常令人沮丧。我分享你的痛苦。 :)

"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0"添加到dependencies文件中的project.json