asp.net mvc - Using Url.Content with semi-relative URL -


I am storing the images of images in my database in an MVC application ... but only a part of the space I'm collecting. For example:

  /headers/image1.jpg /headers/image2.jpg   

Images are actually stored in the following folder:

  ~ / content / images / headers / image1.jpg ~ / content / images / headers / image1.jpg   

In my opinion, I want to do something like this: & lt; Img src = "@ Url.Content (" ~ / content / images ") + Model.imageUrl" />

How can I do this?

Just do it! & lt; Img src = "@ Url.Content (" ~ / content / images "+ Model.imageUrl)" /> As ASP.NET MVC 4, it is valid to use the Tild URL as a straightforward HTML in the form of a razor view engine. URL will parse by:

  & lt; Img src = "~/content/images/@Model.ImageUrl" />    

Comments