开发者

MVC 3 AjaxHelper Ajax.ActionLink vs. Ajax.RouteLink, Ajax.BeginForm vs. AjaxBeginRouteForm

From my understanding

  • Ajax.ActionLink - Generates a link to a specific action in the current controller
  • Ajax.RouteLink - Generate a link based on RouteData provided to the helper

However I have been using MVC 3 and note that Ajax.ActionLink has many overloads which can accept just about anything Ajax.RouteLink can including RouteData, protocol, ActionName, ControllerName etc.

The same goes for Ajax.BeginForm and Ajax.BeginRouteForm

So开发者_JAVA技巧 am am missing something or are the Route versions obsolete?


The .Route versions are used to generate links based on route (name) configurations.

route configuration (ex: global.asax)

routes.MapRoute(
    "faq",
    "pages/faq",
    new { controller = "Faq", action = "Index" }
);

usage in a view - with Html.ActionLink

@Ajax.ActionLink(linkText: "something", controller: "Faq", action: "Index")

usage in a view - with Html.RouteLink

@Ajax.RouteLink(linkText: "something", routeName: "faq")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜