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 ...
随机推荐
- 20165317 java学习总结
20165317 java学习总结 每周作业链接汇总 预备作业1:https://www.cnblogs.com/ningxinyu/p/8341213.html 预备作业2:https://www. ...
- LeetCode 696 Count Binary Substrings 解题报告
题目要求 Give a string s, count the number of non-empty (contiguous) substrings that have the same numbe ...
- Jemter 压测基础(一)——基本概念、JMeter安装使用、分布式测试、导出测试结果、编写测试报告
Jemter 压测基础(一) 1.压力测试的基本概念: 1.吞吐率(Requestspersecond) 服务器并发处理能力的量化描述,单位是reqs/s,指的是某个并发用户数下单位时间内处理的请 ...
- UIWebView 缓存
//存储cookie的方法 - (void)saveCookies { // 创建一个可变字典存放cookie NSMutableDictionary *fromappDict = [NSMutabl ...
- [摘抄] Bezier曲线、B样条和NURBS
Bezier曲线.B样条和NURBS,NURBS是Non-Uniform Rational B-Splines的缩写,都是根据控制点来生成曲线的,那么他们有什么区别了?简单来说,就是: Bezier曲 ...
- iscroll4升级到iscroll5全攻略笔记
前段时间在搞移动终端(移动web)的项目,其中需要用到滚动的功能(html的滚动效果不好,且在低版本上不支持).后面上网找了下资料,发现大部分人都在用iscroll4(下面简称v4),下载下来试了下确 ...
- 记oracle使用expdp将数据导出到asm报错
报错信息如下: ORA-39002: invalid operationORA-39070: Unable to open the log file.ORA-29283: invalid file o ...
- [ Build Tools ] Repositories
仓库介绍 http://hao.jobbole.com/central-repository/ https://my.oschina.net/pingjiangyetan/blog/423380 ht ...
- Tomcat增加Context配置不带项目名访问导致启动的时候项目加载两次
eclipse发布web应用至tomcat,默认方式下访问该项目是需要带项目名称的,例http://localhost:8080/myapp/.现在需要改成这样访问http://localhost.修 ...
- three.js 3d三维网页代码加密的实现方法
http://www.jiamisoft.com/blog/17827-three-js-3dsanweiwangyejiami.html https://www.html5tricks.com/ta ...