Resolving mimetype in Sitecore

Now here is a small nifty trick from the depths of Sitecore. Sitecore contains a /App_Config/MimeTypes.config containing mimetypes for almost every extension possible. To resolve the mimetype for an extension you can use the Sitecore.Resources.Media.MimeResolver:

using Sitecore.Resources.Media;

private string ResolveMimeType(string extension)
  MimeResolver resolver = new MimeResolver();
  return resolver.GetMimeType(extension);

About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.
This entry was posted in c#, Sitecore 6 and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.