开发者

render Url.Action in model

开发者 https://www.devze.com 2022-12-23 07:29 出处:网络
how can i do such thing in model or controll开发者_如何学JAVAer? <%= Url.Action(\"Home\"); %>

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号