Link to a file in MVC 5 ASP.NET

Paul

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

Vince

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

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Direct download link to ASP.NET MVC 5 for VS 2012

From Dev

Direct download link to ASP.NET MVC 5 for VS 2012

From Dev

Returning a link if the file exists in asp.net mvc

From Dev

How to Link to a file in ASP.NET MVC 4 using Razor?

From Dev

Returning a link if the file exists in asp.net mvc

From Dev

asp.net identity authenticate by link / url asp.net mvc 5

From Dev

Checking if file exists in asp.net mvc 5

From Dev

DownloadRangeToStreamAsync and File Save using ASP.NET and MVC5

From Dev

ASP NET MVC 5 Delete File From Server

From Dev

Asp.net MVC5, how to load .hbs file

From Dev

ASP .NET MVC 5 Write javascript in View.cshtml file

From Dev

Configuration.cs file asp.net 5 mvc

From Dev

Asp.net MVC5, how to load .hbs file

From Dev

ASP NET MVC 5 Delete File From Server

From Dev

Configuration.cs file asp.net 5 mvc

From Dev

ASP NET MVC and HTML5 audio - file not playing

From Dev

Detect if file was downloaded successfully in ASP.NET MVC 5

From Dev

ASP NET MVC 5 SessionState

From Dev

ASP NET MVC 5 SessionState

From Dev

How should I link to user profile pages in ASP.NET MVC 5?

From Dev

ASP.NET MVC 5: How do you render a partial view in a div from an action link?

From Dev

HTML Action Link asp.net mvc

From Dev

Asp.Net MVC 5 without Owin?

From Dev

ASP.Net MVC 5 + SignalR + Ninject

From Dev

ASP.NET 5 and the purpose of MVC

From Dev

DateCreated and DateModified in ASP.NET MVC 5

From Dev

Cookies in ASP.Net MVC 5

From Dev

Organizing Areas in ASP.Net MVC 5

From Dev

ASP.NET MVC 5 error handling