Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC - How to get an URL instead of an action link?

I want to embed a URL in an applet parameter.

The only way I know to create automatically the URL is Html.ActionLink(), but I want only the inner HREF attribute, not the whole link.

Is there another way to get what I wan't, other that using Regex on the output of ActionLink() to get the HREF attribute?

like image 716
user2173353 Avatar asked Mar 28 '13 14:03

user2173353


People also ask

What is difference between HTML ActionLink and url action?

Yes, there is a difference. Html. ActionLink generates an <a href=".."></a> tag whereas Url. Action returns only an url.

How do you define area in url action?

write area name as html attribute with anonymus object. you can use actionlink html helper extension method to achieve same thing.


1 Answers

To get only the URL, you can use Url.Action() instead of Html.ActionLink().

It has a number of overloads, so you can give it the name of a route, or the name of the action and the controller, or a number of other options.

Example:

Url.Action("YourAction", "YourController") 
like image 98
Christofer Eliasson Avatar answered Sep 30 '22 11:09

Christofer Eliasson