Paul
Paul

Reputation: 23

Link to a file in MVC 5 ASP.NET

I am trying to create a link to a file inside a folder at the site root. As of now i have a method in the controller that returns a URL to the user folder but when i create the link in the view the path always starts with the name of the current controller, e.g.

http://site/Controller/~/UserContent/userDir/path/file.jpg

My view has the following code:

@Html.ActionLink("view ", ViewData["FSPath"] + img.Path);

How can I remove the Controller value from the URL?

Thanks

Upvotes: 0

Views: 1157

Answers (1)

Vince
Vince

Reputation: 650

You probably want to use @Url.Content. e.g.

@Url.Content("~/UserContent/userDir/path/file.jpg")

Upvotes: 1

Related Questions