views:

38

answers:

1

how can i do such thing in model or controller?

<%= Url.Action("Home"); %>
+2  A: 

You could use the Url property in the controller:

public ActionResult Index()
{
    string url = Url.Action("Home");
    // Do something with the url
    return View();
}

As far as the model is concerned you should avoid using such methods there. The model is passed to the view and the view has access to helper methods which can do the job.

Darin Dimitrov
do you mean UrlHelper.GenerateUrl ? but it has a lot of not clear parameters
kusanagi
There's a `Url` property in the controller which is of type `UrlHelper`. The same you use in your view.
Darin Dimitrov