Reputation: 1364
I am new to ASP.Net Core and I have images in wwwroot/images
dir and I want to display the images when i clicked them. I made a View page to view all the images (and data as well) and when i clicked the images it will go to the detail pages.
Here is the detail page without images displaying.
and here is when the full path of images https://localhost:44325/Catelog/Details/images/book2.jpg
All my images are in wwwroot/images
dir.
Details.cshtml
<div class="col-md-4">
<div>
<img src="@Model.imageUrl" class="detailImage" />
</div>
</div>
So how can I show my images or say how do wwwroot/images
share its resources (maybe ?)
Upvotes: 3
Views: 17468
Reputation: 308
If you model.imageURL equals that:
images/book2.jpg
just add / before @Model.imageUrl like :
<img src="/@Model.imageUrl" class="detailImage" />
If it's like :
book2.jpg
change code like this:
<img src="/images/@Model.imageUrl" class="detailImage" />
Upvotes: 8