【问题标题】:Error 500 after upgrade .net core 1.1 prodution application to .net core 2将 .net core 1.1 生产应用程序升级到 .net core 2 后出现错误 500
【发布时间】:2017-08-23 12:08:13
【问题描述】:

我有一个相对复杂的项目,它是 .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:

有人可以帮忙吗?

【问题讨论】:

  • 错误 500 表示内部服务器错误。您确实应该在 Web 部件上找到任何有用的东西。你必须检查你的服务器的日志。
  • 我在本地运行这个项目。
  • 所以,检查你本地机器的日志。如果您使用 IIS (Express) 运行 - 请参阅 this question,如果您仅使用 Kestrel 运行 - 检查控制台输出。

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


【解决方案1】:

查看stdout日志,问题是ConfigureServices只能取IServiceCollection。我试图在其中注入另一个参数,但项目已编译。

希望这个可以通过智能感知或者IDE运行时发现

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-03
    • 2021-05-14
    • 2021-02-04
    • 2017-07-05
    • 1970-01-01
    • 2019-12-28
    • 2017-04-13
    • 1970-01-01
    相关资源
    最近更新 更多