欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

.NET Framework迁移.NET Core记录

程序员文章站 2024-01-21 20:49:16
...
1.反射
//AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);//原代码
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);

2.上传文件
原代码:HttpPostedFileBase
替换为:IFormFile
需引用:Microsoft.AspNetCore.Http.Features.dll     3.1.9

可参考:https://www.cnblogs.com/leoxuan/articles/11087121.html

3. 当前路径
原代码:HttpContext.Current.Server.MapPath(upUrl)
替换为:AppContext.BaseDirectory


4.判断是否手机端
private static readonly Regex b = new Regex(@"(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino", RegexOptions.IgnoreCase | RegexOptions.Multiline)