Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why don't the images don't show up on my ASP.Net core website?

I have an asp.net core web application and I want to add photos to it but when i try to debug it on IIS express, only the image icon shows up and I'm not quite sure what to do. All of my images are jpg's and are in a folder inside of the wwwroot folder. This is how I reference the photos:

<img src="~/Images/picture.JPG" />

I am not sure what to do to make the photos show up.

like image 568
J.Tian Avatar asked Aug 24 '16 05:08

J.Tian


2 Answers

Make sure you allowing static files to be served:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.UseStaticFiles();
}

You can read more about it from here: https://docs.asp.net/en/latest/fundamentals/static-files.html

like image 113
Ateik Avatar answered Oct 03 '22 06:10

Ateik


Make sure you put your images in correct folder. In this case it should be:

C:\{project_folder}\wwwroot\images
like image 32
Gokce Akcan Avatar answered Oct 03 '22 07:10

Gokce Akcan