将.net核心1.1生产应用程序升级到.net核心2后出现错误500

时间:2017-08-23 12:08:14

标签: asp.net-core asp.net-core-2.0

我有一个相对复杂的项目,即.net core 1.1( .net framework )。

选择.Net Framework是数据库的原因是Oracle和Core Framework不支持Oracle实体数据模型。无论如何,该应用程序在生产中已经运行了大约一年了。

我正在尝试将此项目升级到.net core 2。根据文档here我修改了Startup中的Authentication寄存器,项目编译。

旧代码:

 app.UseCookieAuthentication(new CookieAuthenticationOptions()
    {
        AuthenticationScheme = "Administration",
        LoginPath = new PathString("/Login/"),
        AccessDeniedPath = new PathString("/Login/"),
        AutomaticAuthenticate = true,
        CookieSecure = CookieSecurePolicy.SameAsRequest,                
        AutomaticChallenge = true
     });

更新代码:

 app.UseAuthentication();
    services.AddAuthentication("Administration").AddCookie(options =>
    {
        options.LoginPath = new PathString("/Login/");
        options.AccessDeniedPath = new PathString("/Login/");
        options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest;
    });

我收到错误页面500:

Error Image

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

查看stdout日志后,问题是ConfigureServices只能接受IServiceCollection。我试图注入另一个参数,但项目编译。

我希望这可以通过智能感知或IDE运行时间找到