2011-08-04 7 views
0

Philの記事(http://haacked.com/archive/2010/04/15/sending-json-to-an-asp-net-mvc-action-method-argument.aspx)を読んだことがありますが、以下のようなjsonをどのように取って自分のコントローラーに渡すことができるのか分かりません。私はそれをフォーマットすることに多くのコントロールを持っていないので、私はこれを取って、それからデータを取得する必要があります。asp.netにJSONを渡す方法

{ 
    "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

+0

サーバーからrepsonseは何ですか?私はそれが500だが、あなたはスタックトレースを取得する必要があります知っている。 – Joe

+0

あなたはあなたのコントローラの入力コードに対してあなたが受け入れるオブジェクトとコントローラの投稿コードを記入してください。オブジェクトプロパティとjsonプロパティの名前は正確に一致する必要があります。 –

+0

私のフォーマットを修正してくれてありがとう、Mrchief。 –

答えて

2
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) 
{ 
} 
+0

こんにちはJakub、あなたは何を提案pefectly!ありがとう。私はまた、誤って、次のようにパラメータをリストすると、それも機能することを発見しました。 [HttpPost] public JsonResult Update(int id、string comment、string hoverOverText、 文字列imageURL、文字列navigateURL、文字列スポンサー名、文字列hasCurrentCodeCampYear) { –

関連する問題