URl Helper and HTML Action Methods are not working

Feb 8, 2012 at 7:29 AM
Hi Team, As i have a requirement in one of my project to maintain long URLS, I cam across this solution, but unfortunately I discovered thet Url.Action and HTML.Action methods are not generating url. When I tried to see HTML (ViewSource), it is showing me null. Please let me know If I require to do any setting or it is a bug in latest version. Following is my Global.asax code: routes.MapCodeRoutes( rootController: typeof(Controllers.HomeController), settings: new CodeRoutingSettings { UseImplicitIdToken = true } ); Following is my namespace and controller Method, I am using: namespace Routing.Controllers.sample1.sample2.sample3.sample4.sample5 { public class AccountController : Controller { public ActionResult LogOn() { return View(); } } } Following are the snippets of code I am using generate URL: @Html.ActionLink("Log On", "LogOn", "Account", new { __routecontext = "sample1/sample2/sample3/sample4/sample5/Account/{action}" }, null) Url.Action("Logon", "Account", new { __routecontext = "sample1/sample2/sample3/sample4/sample5/Account/{action}" } But all of these are returning null.
Feb 8, 2012 at 1:45 PM

__routecontext should only contain baseRoute and namespace segments:

@Html.ActionLink("Log On", "LogOn", "Account", new { __routecontext = "sample1/sample2/sample3/sample4/sample5" }, null)

Url.Action("Logon", "Account", new { __routecontext = "sample1/sample2/sample3/sample4/sample5" });

This is a more friendly way of doing it:

@Html.ActionLink("Log On", "LogOn", "~sample1.sample2.sample3.sample4.sample5.Account")

Url.Action("Logon", "~sample1.sample2.sample3.sample4.sample5.Account");

Let me know if these work for you.