Peter Kellner
Peter Kellner

Reputation: 15498

How To Pass JSON into asp.net MVC3 controller formatted like below

I've read Phil's article ( http://haacked.com/archive/2010/04/15/sending-json-to-an-asp-net-mvc-action-method-argument.aspx ) and still can't figure out how I can take json that looks like what I have below and pass it into my controller. I don't have much control over formatting it so I need to take it like this and get the data out of it.

{
  "Id":"720",
  "SponsorName":"Bay Area Association of Database Developers",
  "ImageURL":"~/Images/Sponsors/baadd.org.jpg",
  "NavigateURL":"http://baadd.org/",
  "HoverOverText":"Bay Area Association of Database Developers",
  "Comment":"xx"
}

enter image description here

Upvotes: 0

Views: 1044

Answers (1)

Jakub Konecki
Jakub Konecki

Reputation: 46008

public class SponsorUpdateModel
{
  public int Id {get;set;}
  public string SponsorName {get;set;}
  public string ImageURL {get;set;}
  public string NavigateURL {get;set;}
  public string HoverOverText {get;set;}
  public string Comment {get;set;}
}


public ActionResult Update(SponsorUpdateModel model)
{
}

Upvotes: 2

Related Questions