Pankaj Upadhyay
Pankaj Upadhyay

Reputation: 13574

Can we use Html.ActionLink() for url's outside the application

I need to have links which will point to other website web pages. Currently I am using the following method.

<a href="@reseller.Url">Product-Page</a>

I was wondering if i can use ActionLink for the same. Or ActionLink is just for in-house action methods ? Do I have other better choices or my above usage is correct for the requirement

Upvotes: 0

Views: 2135

Answers (1)

John Gietzen
John Gietzen

Reputation: 49544

The ActionLink method is strictly for "Action Methods", which are methods in a controller that return an ActionResult.

Your above usage is correct.

If you wish to wrap the entire link creation process, you could create your own helper method on the HtmlHelper class to do this.

This answer shows an example of creating an HTML helper for image links:

Is there an ASP.NET MVC HtmlHelper for image links?

Yours would probably be simpler, if you do choose to write a helper.

Upvotes: 1

Related Questions