Skip to main content

Posts

Showing posts with the label MIME

Handling 404 Error for Unknown File Extensions in ASP.NET Core 1.0

In my previous article, I already briefed about Static Files in ASP.NET Core. Now let’s move bit further and know about how ASP.NET treats content files which are of unknown type for any browser. You might be aware that ASP.NET Core middleware serves only those content files which falls under known content types. As of now, it defines close to 400 known file content types. Now question is, how browser will respond to unknown content type files? Let’s understand it better with an example. I’m having an image file named SampleData with extension as .shweta. Here shweta is my custom extension and browser has no information about it. Browser has no idea about how to render this type of file. Please note, this is a static resource placed on wwwroot and has to be served to client. Now quickly open SampleData.shweta in browser and see what happens?           Uhh! This is HTTP 404 Not Found L But is this message correct? If you will go back and cross check your solution