zoukankan      html  css  js  c++  java
  • core1.1 升级到 2.0

    1、直接修改项目 1.1 改成 2.0

    Startup 的修改

    • 去除构造函数中下面的代码
      复制代码
      var builder = new ConfigurationBuilder()
          .SetBasePath(env.ContentRootPath)
          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
      
      builder.AddEnvironmentVariables();
      Configuration = builder.Build();
      复制代码
    • 去除 Configure 方法中下面的代码
      loggerFactory.AddSerilog();
      loggerFactory.AddConsole(Configuration.GetSection("Logging"));
    • IConfigurationRoot 改为 IConfiguration
      复制代码
      public Startup(IConfiguration configuration)
      {
          Configuration = configuration;
      }
      
      public IConfiguration Configuration { get; set; }
      复制代码

    2、授权等要修改下

    app.UseAuthentication();

    //app.UseCookieAuthentication(new CookieAuthenticationOptions
    //{
    // AuthenticationScheme = "member", 
    // AutomaticAuthenticate = true,     // 是否自动启用验证,如果不启用,则即便客服端传输了Cookie信息,服务端也不会主动解析。
    // // 除了明确配置了 [Authorize(ActiveAuthenticationSchemes = "上面的方案名")] 属性的地方,才会解析,此功能一般用在需要在同一应用中启用多种验证方案的时候。比如分Area.
    // LoginPath = "/weixin/draw"// 授权页面
    //});

    services.AddCookieAuthentication(options =>
    {
        options.CookieHttpOnly = true;
        options.CookieName = "xxx";
        options.CookieDomain = "xxx";
        options.LoginPath = "/account/signin";
        options.LogoutPath = "/account/signout";
    });
    复制代码

    改为

    复制代码
    services.AddAuthentication(options =>
    {
        options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
        options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
    })
    .AddCookie(options =>
    {
        options.Cookie.HttpOnly = true;
        options.Cookie.Name = "xxx";
        options.Cookie.Domain = "xxx";
        options.LoginPath = "/account/signin";
        options.LogoutPath = "/account/signout";
    });

     最后更新下 nutget 包

  • 相关阅读:
    UVa 1451 Average (斜率优化)
    POJ 1160 Post Office (四边形不等式优化DP)
    HDU 3507 Print Article (斜率DP)
    LightOJ 1427 Substring Frequency (II) (AC自动机)
    UVa 10245 The Closest Pair Problem (分治)
    POJ 1741 Tree (树分治)
    HDU 3487 Play with Chain (Splay)
    POJ 2828 Buy Tickets (线段树)
    HDU 3723 Delta Wave (高精度+calelan数)
    UVa 1625 Color Length (DP)
  • 原文地址:https://www.cnblogs.com/zxs-onestar/p/7457370.html
Copyright © 2011-2022 走看看