asp.net mvc - MVC3 - Reading GET Variables Into Controller Action -


i have controller action /responses/insert , want able variables url , save them database.

the url this:

/responses/insert?pass=blah&msisdn=blah&sender=blah&message=blah&dca=blah&msg_id=blahsource_id=blah 

here model:

public class response {     public int responseid { get; set; }     public string msisdn { get; set; }     public string sender { get; set; }     public string message { get; set; }     public string dca { get; set; }     public string msg_id { get; set; }     public string source_id { get; set; } } 

can offer advice on how code controller action?

// // get: /response/insert  public actionresult insert() {     return view(); }  

thanks much!

paul

edit 1 - solved (thanks lukled)

    public actionresult insert(response response)     {         if (modelstate.isvalid)         {             responserepository.insertorupdate(response);             responserepository.save();             return redirecttoaction("index");         }         else         {             return view();         }     } 

try this:

public actionresult insert(response response) {     return view(); }  

model binder handle turning get values response object.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -