Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 am am missing something or are the Route versions obsolete?

like image 417
ricardo Avatar asked Jan 24 '26 05:01

ricardo


1 Answers

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")
like image 92
Carlos Guedes Avatar answered Jan 25 '26 21:01

Carlos Guedes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!