HelpPage 生成 Response Sample 报异常:
An exception has occurred while using the formatter ‘JsonMediaTypeFormatter’ to generate sample for media type ‘text/json’. Exception message: One or more errors occurred.
以下尝试解决:
1、
http://www.pooran.in/?p=206
http://stackoverflow.com/questions/15029576/samples-not-working-for-web-api-help-page-when-using-an-entity-framework-complex
2、
config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;//循环引用
config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
3、
去掉model 属性Attribute [JsonIgnore]