Where do you store images for asp.net mvc projects and how do you link to them from the .master site

I have a new asp.net mvc project, and I'm trying to find the best place to store images, as well as how I will link to them from the .master website (in cases where I have header images that I want to show at all pages).

Suggestions or best practices?

+69
image asp.net-mvc
Jun 30 '09 at 16:52
source share
5 answers

What I usually do is create the Images folder inside my Content folder. Where you post your images is really up to you if you agree.

The link to these images from your Site.Master is the same as if you were linking to it from any kind:

<img src="/Content/Images/mylogo.png" /> 

alt text

+92
Jun 30 '09 at 16:54
source share
 <img src="@Url.Content("~/Content/Images/logo.png")" /> 

Using this in the Razor view on MVC 5. Images are saved in / Content / Images.

+21
Jan 14 '14 at 17:44
source share
 <%=Html.Image("~/Content/Images/xxx.png")%> 

This is permitted wherever you are in the site hierarchy. Html.Image is part of the Microsoft.Web.Mvc Futures Assembly.

+8
Jun 30 '09 at 20:50
source share

or in mvc2:

 <img src="<%: Url.Content("~/Images2/landingMain/safety.png") %>" alt="safety" /> 
+2
Jun 21 '12 at 21:12
source share

U should put all your images in the content folder, for example: - Content → Images →. IMG files are the same as style files A content folder such as Content →. Css, therefore, it easily loads images and css, otherwise it will not be executed properly.

+1
Aug 23 '15 at 14:50
source share



All Articles