Home > ASP.NET > CodeFluent Entities: Blobs and the HttpResponse.ContentType

CodeFluent Entities: Blobs and the HttpResponse.ContentType

To serve blobs on the web, CodeFluent Entities generates a HttpHandler which loads and returns a blob from a given URL. A cool feature of this HttpHandler is that it sets the HttpResponse.ContentType property to the HTTP MIME type corresponding to the returned stream, so the end-user’s browser will use the appropriate piece of software to read it. For instance, returning a MP3 file will launch the corresponding default program such as Windows Media Player, Acrobat Reader if it’s a PDF, or Microsoft Word if it’s a DOCX.

The HttpHandler knows two ways to retrieve the MIME type:

  • Using the IIS Metabase (default)
  • Using the Registry

Using Web MIME Types (default)

CodeFluent Entities is a 6 year old product and at the time this feature was developed Internet Information Services (IIS) was in version 6.0. With IIS 7 and IIS 7.5 the metabase is not installed by default so to get MIME types from IIS you need to have the IIS Metabase and IIS 6 configuration compatibility option enabled (cf. screenshot underneath).


Furthermore, the account used to access the metabase needs to be allowed to do so which might not be the case do so. That’s exactly what happened if you got this error:

CodeFluent.Runtime.CodeFluentRuntimeException was unhandled by user code

Message=CF1033: An error has occured trying to read metabase path ‘IIS://localhost/MimeMap’. Current user is ‘NT AUTHORITY\IUSR’.



MessageWithoutCode=An error has occured trying to read metabase path ‘IIS://localhost/MimeMap’. Current user is ‘NT AUTHORITY\IUSR’.

Microsoft provides a tool named MetaAcl which you can use to modify the default permissions that are set on an Internet Information Services (IIS) metabase. So let’s say my web site is ran using the Local Service identity; using the following command line grants the read permission to the Local Service user account to access my IIS metabase:

Metaacl.vbs IIS://localhost/MimeMap “NT AUTHORITY\LOCAL SERVICE” R

Using Registry MIME Types

To use registry MIME types all you need is to set the useWebMimeTypes to false it will switch to registry mode. Here a sample configuration (replace the section name ‘Sample’ by your default namespace):

    <section name="Sample" type="CodeFluent.Runtime.CodeFluentConfigurationSectionHandler, CodeFluent.Runtime" />
  <Sample useWebMimeTypes="false" connectionString="server=(localhost);database=Sample;Trusted_Connection=true" />


  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s