1

我已经安装了 asp.net core rc 2。我正在尝试创建 jwt 令牌身份验证。在 rc 1 中,所有工作人员都非常好。即使你创建一个标准项目,他也没有启动,因为有错误=(纠正错误,我在startup.cs中添加一个代码:

  public void ConfigureServices(IServiceCollection services)
    {
        // Add framework services.
        services.AddApplicationInsightsTelemetry(Configuration);
        var connection = "Data Source=DESKTOP-R3AP4AT\\SQLEXPRESS;Initial Catalog=Guide;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
        services.AddDbContext<GuideContext>(options => options.UseSqlServer(connection));
        services.AddAuthentication();
        services.AddMvc();
    }

添加 project.json 库:

"AspNet.Security.OpenIdConnect.Server": "1.0.0-beta4",

并且有一个错误:错误 所有project.json:

    {
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0-rc2-3002702",
      "type": "platform"
    },
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview1-final",
    "Microsoft.AspNet.Authentication": "1.0.0-rc1-final",
    "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-rc2-final",
    "Microsoft.AspNet.Security.OpenIdConnect" :  "1.0.0-beta3" 

  },

  "tools": {
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    },
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "gcServer": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}
4

1 回答 1

1

不要将不同的 RC 版本混合在一起。您的 project.json 混合了 RC1 和 RC2 模块。

所有这些都必须是 RC2 否则它将无法工作。从旧版本到新版本有十几个重大变化。

"Microsoft.AspNet.Authentication": "1.0.0-rc1-final",
"Microsoft.AspNet.Security.OpenIdConnect" :  "1.0.0-beta3",
"AspNet.Security.OpenIdConnect.Server": "1.0.0-beta4"

这些行是错误的,它们是过时的包。

"Microsoft.AspNetCore.Authentication": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Authentication.OpenIdConnect" :  "1.0.0-rc2-final",
"AspNet.Security.OpenIdConnect.Server": "1.0.0-beta5-final"

应该管用。

于 2016-05-21T14:19:46.200 回答