JSON.Net JsonConverter for DbGeography

大城市里の小女人 提交于 2019-11-30 04:13:27

The issue isn't with your converter. This is a known validation bug that happens when a public property's getter throws in the object graph. This work item tracks the issue:

http://aspnetwebstack.codeplex.com/workitem/740

In the mean time, you should be able to get around it by disabling validation:

config.Services.Clear(typeof(ModelValidatorProvider));

Sorry for the inconvenience.

joelmdev

The bug mentioned by Youssef has since been fixed, but I still ran into issues when creating a custom JsonConverter for DbGeography in that somewhere in the validation process the DefaultBodyModelValidator got stuck in a loop. My solution was not to disable model validation altogether, but to replace the default validator with a derived one that excludes the DbGeography type from deep validation.

So as not to repeat myself, you can see the full solution here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!