Dkong
Dkong

Reputation: 2788

generate URL (without anchor tags) in mvc 2.0

i need to generate a link based on a controller and action but with no anchor tags, ie just generate something like this

http://www.stackoverflow.com/myfavorite/website

Upvotes: 1

Views: 341

Answers (2)

Alexandr
Alexandr

Reputation: 1460

Simply, you can write your own helper:

Html.Action(string action, string controller)

and customize result URL via String.Format()

Upvotes: -1

Swaff
Swaff

Reputation: 13621

You can use Url.Action rather than Html.ActionLink

Example

<%= Url.Action(new { controller = "myfavourite", action = "website" }) %>

Will give you the 'myfavorite/website' part, which you can prepend with your hostname if required.

Upvotes: 3

Related Questions