title: How do I ensure lower case URLs on POST?
body: <p>I am trying to ensure that all URLs used to access my ASP.NET MVC site are lower case. In the event that an upper case letter is in the URL, I'm changing the status code to 301 and changing the location to the lowercase version of the URL with this code:</p>
  
  <pre><code>protected void Application_BeginRequest(object sender, EventArgs e)
  {
      var url = Request.Url.ToString();
      if (Regex.IsMatch(url, @"[A-Z]"))
      {
         Response.Clear();
         Response.Status = "301 Moved Permanently";
         Response.StatusCode = (int)HttpStatusCode.MovedPermanently;
         Response.AddHeader("Location", url.ToLower());
         Response.End();
       }
  }
  </code></pre>
  
  <p>However, recently a co-worker was trying to POST a form to a URL with a capital letter (forgetting about the redirect), but the action (marked with an HttpPost attribute) was not being hit. Looking at the requests in Firebug showed the original POST, but then it returned 301 and issued a GET to the lower case version.</p>
  
  <p>I'm guessing the best solution is to just make sure all POSTs are to the lowercase version of the URL, but I came here to see if there is another way to handle this issue</p>