Asp.net core 学习笔记 2.1 升级到 2.2
首先跟着官网 step by step
https://docs.microsoft.com/en-us/aspnet/core/migration/21-to-22?view=aspnetcore-2.2&tabs=visual-studio
Bug 1
发现一个 odata routing issue
https://github.com/Microsoft/aspnet-api-versioning/issues/361
因为 2.2 router 有升级, 貌似 odata 没有跟上.
https://blogs.msdn.microsoft.com/webdev/2018/08/27/asp-net-core-2-2-0-preview1-endpoint-routing/
目前只好先关上它
options.EnableEndpointRouting = false;
然后继续追踪
https://github.com/OData/WebApi/issues/1707
Bug 2
https://github.com/aspnet/AspNetCore/issues/6166
在做 webapi 又跨域的情况下, 游览器会发送 option request , 然而因为 2.2 有对 http2 之类的升级, 好像导致了 iis 的返回有点问题.
具体原因我就不管了. 反正就是用 work around 顶一顶先.
app.Use(async (ctx, next) =>
{
await next();
if (ctx.Response.StatusCode == )
{
ctx.Response.ContentLength = ;
}
});
持续追踪 https://github.com/aspnet/AspNetCore/issues/4398
Bug 3
serilog-extensions-logging-file 好像不能用了...虽然这东西本来就没有维护了.
那就找替代吧.
https://andrewlock.net/creating-a-rolling-file-logging-provider-for-asp-net-core-2-0/
https://nblumhardt.com/2017/08/use-serilog/
https://github.com/serilog/serilog-settings-configuration
https://stackoverflow.com/questions/40880261/configuring-serilog-rollingfile-with-appsettings-json
https://nblumhardt.com/2016/03/reading-logger-configuration-from-appsettings-json/
https://github.com/serilog/serilog-aspnetcore
https://github.com/serilog/serilog-sinks-file
appsetting.json
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Warning",
"Hangfire": "Warning"
}
},
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": {
"path": "Log/log.txt",
"rollingInterval": 3
}
}
]
},
main.cs
public static void Main(string[] args)
{
CurrentDirectoryHelpers.SetCurrentDirectory();
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", optional: true)
.AddEnvironmentVariables()
.Build(); Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.CreateLogger(); WebHost.CreateDefaultBuilder(args)
.UseUrls("http://192.168.1.152:61547")
.ConfigureSecretFromCloud(skipInDevelopmentMode: true)
.UseSerilog()
.UseStartup<Startup>().Build().Run();
}
替代方案很简单. 但是 2.2 有 bug !
https://github.com/aspnet/AspNetCore/issues/4206
因为 serilog 是在 main.cs 去获取 appsetting.json 然后 setup config 的. 而 2.2 iis 情况下有一个叫 In-Progress 的鬼.
它会把 path 给弄不清楚. 幸好微软团队及时给了 work around 参考上面的 gitHub, 对话下方就有 word around 了.
Asp.net core 学习笔记 2.1 升级到 2.2的更多相关文章
- Asp.Net Core学习笔记:入门篇
Asp.Net Core 学习 基于.Net Core 2.2版本的学习笔记. 常识 像Django那样自动检查代码更新,自动重载服务器(太方便了) dotnet watch run 托管设置 设置项 ...
- ASP.NET Core 学习笔记 第一篇 ASP.NET Core初探
前言 因为工作原因博客断断续续更新,其实在很早以前就有想法做一套关于ASP.NET CORE整体学习度路线,整体来说国内的环境的.NET生态环境还是相对比较严峻的,但是干一行爱一行,还是希望更多人加入 ...
- Asp.net Core学习笔记
之前记在github上的,现在搬运过来 变化还是很大的,感觉和Nodejs有点类似,比如中间件的使用 ,努力学习ing... 优点 不依赖IIS 开源和跨平台 中间件支持 性能优化 无所不在的依赖注入 ...
- ASP.NET Core 学习笔记 第三篇 依赖注入框架的使用
前言 首先感谢小可爱门的支持,写了这个系列的第二篇后,得到了好多人的鼓励,也更加坚定我把这个系列写完的决心,也能更好的督促自己的学习,分享自己的学习成果.还记得上篇文章中最后提及到,假如服务越来越多怎 ...
- ASP.NET Core 学习笔记 第四篇 ASP.NET Core 中的配置
前言 说道配置文件,基本大多数软件为了扩展性.灵活性都会涉及到配置文件,比如之前常见的app.config和web.config.然后再说.NET Core,很多都发生了变化.总体的来说技术在进步,新 ...
- ASP.NET Core 学习笔记 第五篇 ASP.NET Core 中的选项
前言 还记得上一篇文章中所说的配置吗?本篇文章算是上一篇的延续吧.在 .NET Core 中读取配置文件大多数会为配置选项绑定一个POCO(Plain Old CLR Object)对象,并通过依赖注 ...
- Asp.net core 学习笔记 ( Data protection )
参考 : http://www.cnblogs.com/xishuai/p/aspnet-5-identity-part-one.html http://cnblogs.com/xishuai/p/a ...
- Asp.net core 学习笔记 SignalR
refer : https://kimsereyblog.blogspot.com/2018/07/signalr-with-asp-net-core.html https://github.com/ ...
- Asp.net core (学习笔记 路由和语言 route & language)
https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/routing?view=aspnetcore-2.1 https://doc ...
随机推荐
- css学习_css用户界面样式
1.css用户界面样式 a.鼠标样式(记住几个兼容性好的) cursor:default/pointer/move/text; b.轮廓 outline outline:2px solid red: ...
- ping不通,配置dns
vim /etc/resolv.conf nameserver 119.29.29.29 nameserver 182.254.116.116 nameserver 8.8.8.8
- 5.0-uC/OS-III时间管理
1.时间管理 uC/OS-III为用户提供了与时间管理相关的服务. 在uC/OS-III中设置了能提供时基中断的中断源.该中断源提供 10Hz 到 1000Hz 之间的中断(需设置OS_CFG_APP ...
- javaweb(1)之tomcat使用
安装 1.点击下载. 2.解压到一个目录. 3.进入解压后的 bin 目录,双击该文件夹下的 startup.bat 即可运行. 4.若运行成功,会有一个窗口悬停如下: 访问地址: localhost ...
- 【LeetCode每天一题】Combinations(组合)
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: I ...
- 从Win32程序中的主函数中获取命令行参数
在标准C或者Win32控制台程序的main函数中,它们都有两个参数:"argc" 和 "argv",如下所示: int main(int argc, char ...
- redis解决高并发下脏读问题
//解决并发情况下卡脏读的问题 protected function BingFa($mobile, $ent_id){ $obj = EnterpriseMembers::getNewMemberC ...
- hdu4777 树状数组
题意:给了n个数,然后又m次查询,询问[L,R] 内有多少个数与其他的数不互质. 解: 我们首先可以通过处理得出每个数的有效区间,LR 就是 左边L位置上的数 和他不互质, 右边R位置上的数和不互质, ...
- m2e-wtp的作用
描述 Maven3下的项目结构,target目录下会有一个m2e-wtp文件夹,删除掉会自动生成,有什么作用呢? wtp解释 WTP:Web Tools Project Maven集成WTP The ...
- Kubernetes代码解读-apiserver之list-watch
list-watch,作为k8s系统中统一的异步消息传递方式,对系统的性能.数据一致性起到关键性的作用.今天我想从代码这边探究一下list-watch的实现方式.并看是否能在后面的工作中优化这个过程. ...