开发者

How to get just the URL of an Action in an ASP.NET MVC View?

开发者 https://www.devze.com 2022-12-18 13:50 出处:网络
I开发者_如何学C want to get the URL of a route using the same syntax as Html.ActionLink, but don\'t know how to do that from my View.

I开发者_如何学C want to get the URL of a route using the same syntax as Html.ActionLink, but don't know how to do that from my View.

Is there an HtmlHelper extension that works like ActionLink but returns only the URL?

For instance, I want to write:

<img src="<%= Html.ActionUrl("Image", new { id = 42 }) %>" />


Check out:

Url.Action()

Aka:

<img src="<%= Url.Action("Image", new { id = 42 }) %>" />
0

精彩评论

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

关注公众号