由于一些 JS 组件要求 JSON 格式是 PascalCase 格式,新版本 ASP.NET Core 3.0 中默认移除了 Newtonsoft.Json ,使用了微软自己实现的 System.Text.Json 来代替,可以修改继续使用 Newtonsoft.Json 来设置 PascalCase 格式属性名。

Install-Package Microsoft.AspNetCore.Mvc.NewtonsoftJson

           //返回 PascalCase 问题
//services.AddMvc()
// .AddJsonOptions(option => option.JsonSerializerOptions.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver()); services.AddControllersWithViews().AddNewtonsoftJson(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()
{
NamingStrategy = new DefaultNamingStrategy()
});

备注:使用 DefaultContractResolver 是 PascalCase 风格,使用 CamelCasePropertyNamesContractResolver 是 CamelCase 风格。

当然也可以使用默认的 System.Text.Json 来代替

services.AddControllersWithViews().AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null);

SignalR 问题

统一Hub 放在 UseEndpoints 下

SignalRAppBuilderExtensions.UseSignalR(IApplicationBuilder, Action<HubRouteBuilder>)”已过时:“This method is obsolete and will be removed in a future version. The recommended alternative is to use MapHub<THub> inside Microsoft.AspNetCore.Builder.UseEndpoints(...).

客户端迁移

SignalR JavaScript client has changed from @aspnet/signalr to @microsoft/signalr.

REFER:
https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio#jsonnet-support

https://docs.microsoft.com/en-us/aspnet/core/signalr/javascript-client?view=aspnetcore-3.0
https://www.cnblogs.com/dudu/p/10776880.html
https://www.cnblogs.com/stulzq/p/11497624.html

升级 ASP.NET Core 3.0 设置 JSON 返回 PascalCase 格式与 SignalR 问题的更多相关文章

  1. asp.net core 3.0 MVC JSON 全局配置

    asp.net core 3.0 MVC JSON 全局配置 System.Text.Json(default) startup配置代码如下: using System.Text.Encodings. ...

  2. ASP.NET 5 RC1 升级 ASP.NET Core 1.0 RC2 记录

    升级文档: Migrating from DNX to .NET Core Migrating from ASP.NET 5 RC1 to ASP.NET Core 1.0 RC2 Migrating ...

  3. Handle Refresh Token Using ASP.NET Core 2.0 And JSON Web Token

    来源:   https://www.c-sharpcorner.com/article/handle-refresh-token-using-asp-net-core-2-0-and-json-web ...

  4. ASP.NET Core 1.0 开发记录

    官方资料: https://github.com/dotnet/core https://docs.microsoft.com/en-us/aspnet/core https://docs.micro ...

  5. Asp.Net Core 2.0 项目实战(8)Core下缓存操作、序列化操作、JSON操作等Helper集合类

    本文目录 1.  前沿 2.CacheHelper基于Microsoft.Extensions.Caching.Memory封装 3.XmlHelper快速操作xml文档 4.Serializatio ...

  6. ASP.NET Core 2.0升级到3.0的变化和问题

    前言 在.NET Core 2.0发布的时候,博主也趁热使用ASP.NET Core 2.0写了一个独立的博客网站,现如今恰逢.NET Core 3.0发布之际,于是将该网站进行了升级. 下面就记录升 ...

  7. Asp.net Core 1.0.1升级到Asp.net Core 1.1.0 Preview版本发布到Windows Server2008 R2 IIS中的各种坑

    Asp.net Core 1.0.1升级到Asp.net Core 1.1.0后,程序无法运行了 解决方案:在project.json中加入runtime节点 "runtimes" ...

  8. 升级 asp.net core 1.1 到 2.0 preview

    Upgrading to .NET Core 2.0 Preview 1 更新 依赖的类库 改为 标准库 2 web app  更改 csproj 文件---升级版本 <PropertyGrou ...

  9. asp.net core 2.0 Json结果的格式

    asp.net core 2.0 默认返回的结果格式是Json, 并使用json.net对结果默认做了camel case的转化(大概可理解为首字母小写). 这一点与老.net web api 不一样 ...

随机推荐

  1. C# rename files

    static void RenameFiles() { string sourceDir = @"D:\ll"; string[] allFiles = Directory.Get ...

  2. ES6箭头函数-2

    以下来文字来自阮大神所著书籍摘记.为了加深记忆.本人就手动敲了一遍(相关代码本人也执行过,可保证运行通过.) 箭头函数注意事项: 1) 函数体内的this对象就是定义时所在的对象,而不是使用时所在的对 ...

  3. Dynamics 365 CE将自定义工作流活动程序集注册到磁盘并引用其他类库

    我是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面 ...

  4. zabbix4.0搭建2

    server端(ip 192.168.200.15) proxy端(ip 192.168.200.22) agent端(ip 192.168.200.12) server端: #安装数据库 [mari ...

  5. CodeForces 1260D(二分+贪心+差分)

    题意 https://vjudge.net/problem/CodeForces-1260D 有m个士兵,t秒,你要带尽可能多的士兵从0去n+1,且他们不能被杀死.路上有一些陷阱,陷阱d[i]会杀死能 ...

  6. 往对象数组里面添加相同的key 不同的value 和删除相同的key值

    应用场景:后盾字段没有发给你  自己补充数据 <div v-for="item in list" :key="item.id"> <p> ...

  7. base46+url编码

    base64解密+unquote url编码 html = ''' JTdCJTIyc3RvcmUlMjIlM0ElN0IlMjJnYW1lTGlicmFyeSUyMiUzQSU3QiUyMmRpc2 ...

  8. C++ STL multiset

    multiset的例子,允许集合内的元素是重复的 #include <iostream> #include <set> using namespace std; int mai ...

  9. 【声明式事务】Spring事务特性(二)

    spring所有的事务管理策略类都继承自org.springframework.transaction.PlatformTransactionManager接口. 其中TransactionDefin ...

  10. <Array> 277 243 244 245

    277. Find the Celebrity knows(i, j): By comparing a pair(i, j), we are able to discard one of them 1 ...