Using Resources / Resx objects on a Web Site
In an earlier post I showed how you can take any Resources object(especially PinnedBufferMemoryStream and UnmanagedMemoryStreamWrapper) and obtain it’s byte[]. Unfortunately on the web this is not sufficient because when the byte[] is sent to a client. The browser expects a mime type header to tell it how to handle the byte[]. A partial solution is to simply map each mnemonic to a specific known mime type . This is a fragile solution. If you are doing localization then a mnemonic such as SiteLogo may be different mime types in different languages, for example: en-US: image is a .bmp es-Mx: image is a .png fr-CA image is a .gif (animated) dk-DK image is a .tiff Of course, one could simply specify to human-ware that they must all be the same . In reality, if the web-site is a commercial product, this will usually break down. The practical solution is to use Magic Numbers . Use the magic number to determine the file type, then lookup the mime type bas