core1.1 升级到 2.0
2024-08-25 11:51:28
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 包
最新文章
- We7<;001>;--We7 CMS之报错: HTTP 错误 404.0 - Not Found 您要找的资源已被删除、已更名或暂时不可用。
- 阿牛的EOF牛肉串[HDU2047]
- To follow the path
- webkit,HTML5头部标签
- contentProvider内容提供者
- idea 使用问题总结
- debian支持ll命令
- isHiden和isVisible的区别(isVisible更可靠)
- 使用Swing实现简易而不简单的文档编辑器
- 解决Hystrix Dashboard 一直是Loading ...的情况
- 两道很好的dp题目【4.29考试】
- LOJ#2087 国王饮水记
- 最简单的原生js和jquery插件封装
- Jupyter Notebook启动不会自动打开浏览器,每次都要自己打开浏览器输入网址
- 包装类接受string 会自动将数字类型string转换成对应得包装类型
- Js高级 事件 对象
- Java集合之HashSet源码分析
- Python-ccs高级选择器 盒模型
- 每日英语:Doc, Do I Need A Juice Cleanse?
- innodb表锁情况
热门文章
- <;山月记>;:中岛敦 -选段
- 【转】 g++编译时对&#39;xxxx&#39;未定义的引用问题(undefined reference to)
- 非常棒的——python Deep learning 学习笔记
- Cisco常用配置和命令
- codeforces 848B Rooter&#39;s Song 思维题
- jquery插件中找到好玩插件 http://www.jq22.com/
- Xmanager Power Suit 6.0.0009 最新版注册激活
- Integer To Roman leetcode java
- shiro中INI配置
- python:extend (扩展) 与 append (追加) 之间的天与地