Home » ASP.NET » Azure CDN Blob Storage Case Sensitive Issue

Azure CDN Blob Storage Case Sensitive Issue


If you’ve done any work with Azure Blob storage, you already know that Blob storage is case sensitive.  If you’ve hooked the Azure CDN to blob storage, it is also case sensitive.

You are probably reading this article because you’ve already run into this problem.

We ran into this problem when we were moving a site from an existing CDN to Azure.  The current site was on domain A and the resources hosted by the CDN were on domain B.  But the URLs to those resources were in various cases.  To make matters worse, there were multiple sites.  So it wasn’t a simple matter of just fixing up the case of one site.

So we were looking for some way to make the CDN case insensitive, which you can’t do, when I finally thought, “Why don’t we make it so that it doesn’t matter with a response filter?”  I’ve done this before when I needed to make global changes and it worked well.

Then I remembered, the URL Rewriting module for IIS7 does this for us.  And since this module is installed by default on Azure, all we needed to do was:

  • Make everything in blob storage lowercase
  • Install the redirect rules in web.config

Here is the web.config rules:

    <rule name="CSCAssets" preCondition="IsHtml"
      <match filterByTags="Img"
         pattern="http://(www\.)?domain\.com/(.*)" />
      <action type="Rewrite"
         value="http://domain.com/{ToLower:{R:2}}" />
            <conditions logicalGrouping="MatchAny" />
      <preCondition name="IsHtml">
         <add input="{RESPONSE_CONTENT_TYPE}"
            pattern="^text/html" />

This will force any URL pointing to http://www.domain.com or http://domain.com to point to http://domain.com and force it all to lowercase on the way back to the client’s browser.


Other post in ASP.NET

Related Post

  • C# “” better than string.Empty?C# “” better than string.Empty? I recently read an article that argued that “” is “Better than String.Empty” The argument is that since string.Empty doesn’t work in all situations, we should not use it at all.  He […]
  • What is the global keyword in CSharp?What is the global keyword in CSharp? During the Christmas break, I received the following question: What does C# global keyword actually do? Code example, from table adapter […]
  • Unrecognized Tag Prefix or Device Filter ‘asp’Unrecognized Tag Prefix or Device Filter ‘asp’ One of the companies I work for recently took over a project from another vendor.  As we started to maintain the site, we noticed that we could not drag and drop controls onto the page […]
  • ASP.NET Dynamic ValidatorASP.NET Dynamic Validator One of the controls that was added to ASP.NET 3.5 in the SP1 release was the Dynamic Validator control. I completely missed it. What it does is pretty cool.  But it doesn’t […]
  • ASP.NET Cross Domain Form SubmissionASP.NET Cross Domain Form Submission Not to be confused with cross page posting, cross domain submission allows us to post the contents of an ASP.NET form to a completely different domain. To achieve this we will need to […]

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer focusing on ASP.NET, C#, Node.js, JavaScript, HTML, CSS, BootStrap, and Angular.JS. Does your team need additional help in any of the above? Contact Dave today.

  • Fren Dee Bee

    Thanks for sharing this solution. I’ve been wondering about this case sensitive issue before.

  • Ved

    Thanks for the great solution .