There is a code on the razor page, like this,
<img src="Images/Tree.jpg" asp-append-version="true" width="286" height="135" />
After run, the page can not display the picture, is there any wrong?
Your Images
folder should be placed under wwwroot
.
And try this code:
<img src="~/Images/Tree.jpg" asp-append-version="true" width="286" height="135"/>
For more details,you can see this link.
If your Images
static files are outside of the wwwroot
folder, to serve these files and make it work as expected, you can try:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
//...
app.UseStaticFiles();
app.UseFileServer(new FileServerOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(env.ContentRootPath, "Images")),
RequestPath = "/Images"
});
//...
Then you can enter the URL to access it.