In my controller I got action:
[HttpGet]
public ActionResult CreateAdmin(object routeValues = null)
{
//some code
return View();
}
As previously mentioned, you cannot pass an entire object to an HTTPGET Action. However, what I like to do when I do not want to have an Action with hundreds of parameters, is:
Thus, say you have this class representing all your input fields:
public class AdminContract
{
public string email {get;set;}
public string nameF {get;set;}
public string nameL {get;set;}
public string nameM {get;set;}
}
You can then add a GET Action that will expect only one, string parameter:
[HttpGet]
public ActionResult GetAdmin(string jsonData)
{
//Convert your string parameter into your complext object
var model = JsonConvert.DeserializeObject(jsonData);
//And now do whatever you want with the object
var mail = model.email;
var fullname = model.nameL + " " + model.nameF;
// .. etc. etc.
return Json(fullname, JsonRequestBehavior.AllowGet);
}
And tada! Just by stringifying and object (on the front end) and then converting it (in the back end) you can still enjoy the benefits of the HTTPGET request while passing an entire object in the request instead of using tens of parameters.