tags:

views:

103

answers:

2

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?

A: 

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 */}
);
womp
A: 

Did you checked out mvc features assembly?It contains html helpers which you want

Tadeusz Wójcik