This question already has answers here:
Closed 2 years ago.
I have a WebApi project with a folder called "images".
I want to access the images directly but I keep getting 404 with message "No type was found that matches the controller named 'images'."
I did the same thing on MVC project and it always worked well, I don't know why in WebApi I can't access files.
I'm sure the file is there, I see it in the directory.
Example request: GET http://localhost:49873/images/20180704003126241.png
Under a default configuration WebAPI won't serve static files for you. You need to either
- Set up a controller on the WebAPI endpoint that will get the files and return a
FileResult
- Configure static file handling middleware
9 times out of 10 you'll want the second one. Note that the default configuration for Microsoft's static file middleware is to serve static content out of wwwroot
so you'll probably need to put your images folder there.