nancy - Nancy v2 中的 Nancy.Json.JsonSettings
问题描述
我正在从 Nancy 1.4.5 -> 2.0 升级我的项目
我有错误:
public class AppBootstrapper : AutofacNancyBootstrapper
{
private readonly ILifetimeScope _scope;
public AppBootstrapper(ILifetimeScope scope)
{
_scope = scope;
}
protected override ILifetimeScope GetApplicationContainer()
{
return _scope;
}
protected override void ApplicationStartup(ILifetimeScope container, IPipelines pipelines)
{
JsonSettings.MaxJsonLength = int.MaxValue;
JsonSettings.RetainCasing = true;
base.ApplicationStartup(container, pipelines);
}
}
}
Error CS0103 The name 'JsonSettings' does not exist in the current context
我该如何解决这个问题?
解决方案
我在类中添加了方法AppBootstrapper
:
public class AppBootstrapper : DefaultNancyBootstrapper
{
public override void Configure(INancyEnvironment environment)
{
environment.Json(retainCasing: true);
}
... other methods
}
并添加maxJsonLength
到web.config
:
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483647"/>
</webServices>
</scripting>
</system.web.extensions>
推荐阅读
- node.js - Unable to upload file to S3 due to write EPIPE Networking Error
- html - Make divs on the top of the other div
- c# - C# - How to insert bulk data in Excel via Microsoft Office Interop Excel
- php - apache/php/oci 自动用问号替换 unicode 字符 - 如何?
- javascript - vue-cli eslint 没有捕获错误
- php - 将 guzzle 响应数据推送到数组并传递给 laravel 中的查看
- steam - 如何获取给定 Steam 应用程序的所有所有者?
- typescript - TypeScript 错误:事件处理程序的“对象”类型上不存在属性“目标”
- ruby - Ruby rspec将带有字符串的模拟哈希转换为带有符号的哈希
- sql - SQL Server 将三个不同的列连接成逗号分隔且没有重复值