Home > ASP.NET > Blob Http Handler

Blob Http Handler


In ASP.NET, if you need to display a blob (Binary Large Object) such as an image, a video or a file, you’ll need to provide an URL to your display control. When storing blobs in database, a standard practice is to create a web page such as a blob.aspx to which you provide the blob’s id as parameter and which the page will load and display so that you can set your display control’s source to that URL.

Actually, CodeFluent Entities automatically generates a HTTP Handler which precisely does all the work described previously: thanks to it you’ll retrieve an URL pointing to your blob and which you’ll be able to use in your display controls.

To use it you need to register it in your web.config file as:

<system.web>
(...)
    <httpHandlers>
      (...)
      <add verb="GET" path="blobhandler.ashx" type="Sample.Web.HttpHandler, Sample, Version=1.0.0.0"/>
    </httpHandlers>
(...)
</system.web>

Note: Using IIS 7.x and the Integrated Pipeline mode, custom handlers should be added in the system.webServer/handlers section.

And there you go: you can now use this http handler to retrieve your blobs!

By the way, CodeFluent Entities also provides some extra controls (e.g. BinaryLargeObjectControl and the BinaryLargeObjectField) in its web runtime to let you easily display them in your ASP.NET web pages.

Categories: ASP.NET Tags: ,
  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