Normally IE (or other browser) will pass throw header the content type for a uploaded file.
Unfortunetly this seems impossible with "Silverlight".
We have a simple upload where the user can select a file from file system and then upload to the server.
We need to pass the "content type" to the server because the server may not know the file extension and content type.
Here is a simple way to obtain contenttype from file extention, but isn't available on silverlight.
Even if it's possible it is not viable because of security and access purpose of different clients desktop.
Any idea on how i can retreive "content type" of uploading file in a silverlight application?
private string GetContentType(string fileName)
string contentType = "application/octetstream";
string ext = System.IO.Path.GetExtension(fileName).ToLower();
Microsoft.Win32.RegistryKey registryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
if (registryKey != null && registryKey.GetValue("Content Type") != null)
contentType = registryKey.GetValue("Content Type").ToString();