Invoke MVC controller action method not with action name but with http method type in ajax call, like below,
Note -- the below needs to work in conventional routing and not with attribute based routing.
$.ajax({ type: "POST", url: "ControllerName", contentType: "application/json; charset=utf-8", data: { data: "yourdata" }, dataType: "json", success: function(recData) { alert('Success'); }, error: function() { alert('A error'); } });
Am have a controller named test and with multiple action methods test - GetData (http method type GET) test - GetdataById (http method type GET with parameter)
test - valuecheck() (http method type Post) test - insertNew(Create Model)(http method type Post with model)
In the above ajax call if i pass controller name as test and method type as Get W/O id as parameter it should invoke "GetData" if i passing Id it should invoke GetdataById, the same for post method.
I have tried out using Attribute based routing it works for few of them but i need to have it conventional way.
I have tried out using Attribute based routing it works for few of them but i need to have it conventional way.