I would like to handle requests differently depending upon the MIME type. For example, I have PDF\'s, images and other media files that I would like to prohibit access to ba
Cross-posting from Why would Reflection search suddenly not find anything?
The good news is that the MimeMapping class and its GetMimeMapping method seem like they might be made public in .NET 4.5.
However, this means that the code given in the above answer would break, since it’s only searching for GetMimeMapping among NonPublic methods.
To ensure compatibility with .NET 4.5 (but preserve functionality in .NET 4.0 and earlier), change…
getMimeMappingMethod = t.GetMethod("GetMimeMapping",
BindingFlags.Static | BindingFlags.NonPublic);
…to:
getMimeMappingMethod = t.GetMethod("GetMimeMapping",
BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);