Home > OS >  Dsiplay image from wwwroot
Dsiplay image from wwwroot

Time:07-07

I want to show my image which is in wwwroot/Uploads if i put localhost/wwwroot/imageName.extension file is not showing but if i remove wwwroot and pass only localhost/Uploads/imageName.extension then file is able to display.But i need it as the first one please help me i shall be very thankful to you. https://localhost:44362/wwwroot/Uploads/img23.png I want this image to display by providing the above url but in this it is unable to show https://localhost:44362/Uploads/img23.png In this case it is able to display, but i don't need this. I need it like the above i wrote. https://localhost:44362/wwwroot/Uploads/img23.png (My requirement).

CodePudding user response:

The wwwroot folder is a feature that comes in with ASP.NET 5.0.

All of the static files in your project should goes into this folder. These are assets that the app will serve directly to clients, including html, css, javascript and image files. The wwwroot folder is the root of your web site.

So http://localhost:port/ points to wwwroot - all URLs for static content are relative to the wwwroot folder (you can use paths that reflects directory structure of your wwwroot).

So then - if you want to have this /wwwroot/ element in your URL you need to create another folder called wwwroot inside your wwwroot directory (what a loop)

CodePudding user response:

I you really want it that way, create a wwwroot folder inside your wwwroot folder and move the files there. This should be your final structure

wwwroot
->wwwroot
-->Uploads
--->img32.png
  •  Tags:  
  • c#
  • Related