Url helpers allows you to render HTML links and raw URLs. The output of these helpers is dependent on the routing configuration of your ASP.NET MVC application.
HTML Element | Example |
---|---|
Relative URL | @Url.Content(“~/Files/asp.netmvc.pdf”) Output: /Files/asp.netmvc.pdf |
Based on action/controller | @Html.ActionLink(“About Us”, “About”, “Home”) Output: <a href=”/Home/About”>About Us</a> |
@Html.ActionLink(“About Me”, “About”, “Home”, “http”,”www.dotnet-tricks.com”, null,null,null) Output: <a href=”http://www.dotnet-tricks.com/Home/About “>About Me</a> |
|
Raw URL for Action | Url.Action(“About”, “Home”) Output: /Home/About |