Is there any C # code that accepts an existing controller, parses its public Action methods, and generates a JavaScript proxy class so that it can be easily called with other Javascript code? I already know that we can use jquery to create $ .post and $ .get to call our ajax services, but I believe that the process can be simplified by not specifying the relative URL of the AJAX web service URL and the parameter name for each input parameters.
For example, let's say we have the following C # controller:
public class CustomerController : Controller
{
public JsonResult Create(string name, string address)
{
return new JsonResult {Data = 11111};
}
public JsonResult Update(int id, string name, string address)
{
return new JsonResult {Data = true};
}
}
I would like to call the action methods of the AJAX controller using the following method.
Proxy.Customer.Create("Scott Gu", "Somewhere in Redmond").done(function(id) {
Proxy.Customer.Update(id, "Scott Gu", "Somewhere in Seattle");
});
Is there a project that allows me to do this?
Update
, , , . -, , SignalR, Phil Haack Controller Inspector. , , , , ..
getter .
https://github.com/Haacked/CodeHaacks/blob/master/src/MvcHaack.ControllerInspector/ControllerDetailer.cs
2
Doh. - JavaScript. .