Reputation: 3532
I've tried over ten various methods of referencing in image within a view (Please don't ask why I'm doing it this way). Anyway obviously one of the biggest problems is that I can never escape the route, even specifying http://localhost:2324:/x/y/img.jpg is pointless.
Is there actually a way referencing an image simply via using file paths?
edit: Pretty sure you can escape the root, Here's an example:
<%= ("<img src=”../../vehicleimages/" + Model.vehicleid + ".jpg” width=“250“ height=“300“ />")%>
The result of this would be:
<img src=”../../vehicleimages/b480b00e-c725-40fe-a5c2-277e82c5b1d9.jpg” width=“250“ height=“300“ />
All good, however if I click the link within browser source code, it sends me to the following:
http://localhost:4716/vehicle/details/vehicleimages/b480b00e-c725-40fe-a5c2-277e82c5b1d9.jpg%E2%80%9D
I want http://localhost:4716/vehicleimages/b480b00e-c725-40fe-a5c2277e82c5b1d9.jpg
Upvotes: 0
Views: 153
Reputation: 10814
I think it's your quotation marks that messes things up. Instead of:
<%= ("<img src=”../../vehicleimages/" + Model.vehicleid + ".jpg” width=“250“ height=“300“ />")%>
...try either:
<img src="../../vehicleimages/<%= Model.vehicleid %>.jpg" width="250" height="300" />
...or:
<%= ("<img src=\"../../vehicleimages/" + Model.vehicleid + ".jpg\" width=\"250\" height=\"300\" />") %>
Upvotes: 2