I am working on developing an API that allows users to save polygons on the server using ASP.NET MVC 5. Can anyone guide me on how to properly format the AJAX parameters for posting requests with DbGeography? This is what I have tried so far:
$.ajax({
url: '/api/map',
type: 'POST',
data: {
Title: 'My Title',
MyGEOG: {
WellKnownText: 'POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10))'
}
}
});
Here is my MVC action method signature:
[HttpPost]
[Route("map")]
public JsonResult Post(MyShape newShape) {...}
In addition, here's my MyShape
class:
public class MapShape
{
public string Title { get; set; }
public System.Data.Entity.Spatial.DbGeography MyGEOG { get; set; }
}
When debugging the action, I notice that newShape.Title
correctly displays as My Title
, but MyGEOG
is null during the AJAX post request. Can someone advise on the correct parameter format to successfully post as a DbGeography
type?