I would like to be able to build a link to a controller action inside of my controller. I really want to do something like:
<%= Html.BuildUrlFromExpression<Controller>(x => x.ActionName(param)) %>
...except in the controller.
Any way to do this?
I would like to be able to build a link to a controller action inside of my controller. I really want to do something like:
<%= Html.BuildUrlFromExpression<Controller>(x => x.ActionName(param)) %>
...except in the controller.
Any way to do this?
You could play around with the HtmlHelper methods. That's what the framework uses internally.
string myLinkText = HtmlHelper.GenerateLink(
new RequestContext(this.HttpContext, this.RouteData),
RouteTable.Routes,
"MyLinkText",
"RouteName",
"ActionName",
"ControllerName",
this.RouteData.Values,
new Dictionary<string, object>() {/* attributes here */}
);
Did you checked out mvc features assembly?It contains html helpers which you want