Search code examples
asp.net-mvcasp.net-mvc-3razor

right way to specify the src for an image in MVC3


I have the following code:

<img src="images/img2.jpg" alt="" title="" />

Is this correct for Layout.cshtml and partial views?

Should I instead specify the source using something like @URl?


Solution

  • This will probably gonna break. The below one is the right way of doing it :

    <img src="@Url.Content("~/images/img2.jpg")" alt="" title="" />