aspnet / StaticFiles

[Archived] Middleware for handling requests for file system resources including files and directories. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
114 stars 72 forks source link

Return HTTP 404 when FileNotFoundException is thrown when attempting to send a file #232

Closed natemcmaster closed 6 years ago

natemcmaster commented 6 years ago

Resolves https://github.com/aspnet/Home/issues/2775

If a file disappears between the File.Exists and File.Open, or if the file is a broken symlink, static files throws an uncaught exception, causing HTTP 500. This change catches the FileNotFoundExcpetion and returns HTTP 404 instead.

Tratcher commented 6 years ago

@natemcmaster this is incomplete/buggy. Revert and we'll keep iterating.

natemcmaster commented 6 years ago

https://github.com/aspnet/StaticFiles/commit/3cd6add095e8a4feccbd7f0886ab3a2c293cfd5f