i am new in mvc but have good experience in webform. when we call any page method by jquery then page method has to be static and must have webmethod attribute in asp.net webform but in case of asp.net mvc when we call any controller method by jquery then that method can be as normal like public method. so i just need to know that how it is possible for jquery to call controller method from outside. i search this by google but found no discuss on this issue. so please anyone who have in depth knowledge please discuss this in detail. thanks
Share
It’s just like requesting any ASP.Net-MVC web page synchronously. It responds essentially the same way for synchronous and asynchronous requests.
It will work because you have:
Defined the return type of the controller method as
ActionResultor any type that inherits from it , likeViewResultorJsonResult,Ensured the returned value of the method to be of this same type (of course — or you’d get compile-time error!) e.g.:
Placed this method inside an object that inherits from the System.Web.Mvc.Controller class.
Mapped a route in Global.asax that matches the URL of the the request and routes it to the specified controller & action
ActionResult defines only one public method signature:
And the framework defines a concrete version for each variant of ActionResult. But you don’t really need to know the inner-workings of ExecuteResult().
The MVC framwork does all the coordination, while giving you lots of entry-points to re-configure the defaults (conventions). It sets up the ControllerContext, calls ExecuteResult(), creates all the default HTTP headers (which you can modify from inside the controller if you need to) for you, etc.