Case-sensitive Azure BLOB Urls-Fix

Blob Urls are case sensitive.  If you had ever stored file or image in a windows azure blob container then you need to access the url in exact case otherwise you will get blob NOT found error.  To resolve this issue

While writing blob always use lower case.

While reading blob convert your url to lowercase and redirect to blob.

For example you can write HttpHandler or HttpModule to redirect to your blob after.  Here is the simple code snippet.

public class BlobModule : IHttpModule    {
public void Dispose()        {            //throw new NotImplementedException();        }
public void Init(HttpApplication context)        {            context.BeginRequest += new EventHandler(context_BeginRequest);        }
void context_BeginRequest(object sender, EventArgs e)        {

string contextUrl=HttpContext.Current.Request.Url.LocalPath.ToLower();

if (contextUrl.Contains(“myfile/”))            {

string blobUrl = RoleEnvironment.GetConfigurationSettingValue(“BlobOrCdnUrl”) + RoleEnvironment.GetConfigurationSettingValue(“ContainerName”) + contextUrl;                HttpContext.Current.Response.Redirect(blobUrl, true);

}        }    }

And then from your web.config you can add the following snippet under module.

<modules runAllManagedModulesForAllRequests=”true”>

<add name=”myname” type=”mynamespace.blobmodule,myassembly” preCondition=”integratedMode” />

</modules>

Thats it.  Now your blob can be accessed using mixed url.