Asp.net mvc 在没有Json.Net的MVC中将DbGeography序列化为Json

Asp.net mvc 在没有Json.Net的MVC中将DbGeography序列化为Json,asp.net-mvc,json,Asp.net Mvc,Json,目前,我必须将所有DbGeography类型设置为null,然后才能将其转换为Json。有没有办法为这种类型添加新的转换器?我知道我可以使用Json.Net并在模型中添加DbGeography类型的转换器,但我们不想使用Json.Net //Json converter fails to convert this. deviceInfo.DeviceData.DeviceLocation = null; return Json(deviceIn

目前,我必须将所有DbGeography类型设置为null,然后才能将其转换为Json。有没有办法为这种类型添加新的转换器?我知道我可以使用Json.Net并在模型中添加DbGeography类型的转换器,但我们不想使用Json.Net

        //Json converter fails to convert this. 
        deviceInfo.DeviceData.DeviceLocation = null;

        return Json(deviceInfo);

我很难相信微软会让MVC的JsonResult不可扩展

你为什么不能扩展它?您可以使用JsonResult作为基础创建一个CustomJsonResult,并在其中添加任何额外的逻辑。我在哪里添加逻辑?重写ExecuteSult方法