As already 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 the following:
- Create a class that will encapsulate all the necessary parameters
- Pass the string value to my HTTPGET action
- Convert string parameter to actual object that is used by my GET action.
So, let's say you have this class representing all of 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;} }
Then you can add a GET action that only one, string parameter will expect:
[HttpGet] public ActionResult GetAdmin(string jsonData) {
And tada! Just by string and object (at the front end), and then converting it (at the end), you can still take advantage of the HTTPGET request by passing the entire object in the request, rather than using dozens of parameters.
user7100321
source share