首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Nancy v2中的Nancy.Json.JsonSettings

Nancy v2中的Nancy.Json.JsonSettings
EN

Stack Overflow用户
提问于 2019-07-26 02:07:22
回答 1查看 321关注 0票数 1

我正在从Nancy 1.4.5 -> 2.0升级我的项目

我有错误:

代码语言:javascript
复制
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

如何解决此问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-26 03:13:19

我在AppBootstrapper类中添加了方法:

代码语言:javascript
复制
public class AppBootstrapper : DefaultNancyBootstrapper
{
    public override void Configure(INancyEnvironment environment)
    {
        environment.Json(retainCasing: true);
    }
    ... other methods
}

并在web.config中添加了maxJsonLength

代码语言:javascript
复制
<system.web.extensions>
  <scripting>
    <webServices>
      <jsonSerialization maxJsonLength="2147483647"/>
    </webServices>
  </scripting>
</system.web.extensions>
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57207890

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档