how can i do such thing in model or controll开发者_如何学JAVAer?
<%= Url.Action("Home"); %>
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.
精彩评论