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 包

最新文章

  1. We7<001>--We7 CMS之报错: HTTP 错误 404.0 - Not Found 您要找的资源已被删除、已更名或暂时不可用。
  2. 阿牛的EOF牛肉串[HDU2047]
  3. To follow the path
  4. webkit,HTML5头部标签
  5. contentProvider内容提供者
  6. idea 使用问题总结
  7. debian支持ll命令
  8. isHiden和isVisible的区别(isVisible更可靠)
  9. 使用Swing实现简易而不简单的文档编辑器
  10. 解决Hystrix Dashboard 一直是Loading ...的情况
  11. 两道很好的dp题目【4.29考试】
  12. LOJ#2087 国王饮水记
  13. 最简单的原生js和jquery插件封装
  14. Jupyter Notebook启动不会自动打开浏览器,每次都要自己打开浏览器输入网址
  15. 包装类接受string 会自动将数字类型string转换成对应得包装类型
  16. Js高级 事件 对象
  17. Java集合之HashSet源码分析
  18. Python-ccs高级选择器 盒模型
  19. 每日英语:Doc, Do I Need A Juice Cleanse?
  20. innodb表锁情况

热门文章

  1. <山月记>:中岛敦 -选段
  2. 【转】 g++编译时对'xxxx'未定义的引用问题(undefined reference to)
  3. 非常棒的——python Deep learning 学习笔记
  4. Cisco常用配置和命令
  5. codeforces 848B Rooter's Song 思维题
  6. jquery插件中找到好玩插件 http://www.jq22.com/
  7. Xmanager Power Suit 6.0.0009 最新版注册激活
  8. Integer To Roman leetcode java
  9. shiro中INI配置
  10. python:extend (扩展) 与 append (追加) 之间的天与地