Reputation: 25
I have a html page and like to insert a image. I have the following html code:
<img src="../Images/logo.jpg" alt="Logo" height="50">
I decided to take "../Images/logo.jpg" as source because my logo.jpg is located in the folder two levels up from the current folder in the folder Images. But it can't find the picture, when I look at the website. What would be the right src for my image and why? Thanks for your help!
Edit: I fixed my problem by add to my class Startup.cs the following code:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), @"Styles")),
RequestPath = new PathString("/Styles")
});
}
Upvotes: 0
Views: 285
Reputation: 5713
Going back once with ../ will lead you to your view directory, you have to go back once and then go to Images like so :
<img src="../../Images/logo.jpg" alt="Logo" height="50">
Upvotes: 1