Guest User

Untitled

a guest
Oct 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. protected void Application_BeginRequest(object sender, EventArgs e)
  2. {
  3. //If upper case letters are found in the URL, redirect to lower case URL.
  4. if (Regex.IsMatch(HttpContext.Current.Request.RawUrl.ToString(), @"[A-Z]") == true)
  5. {
  6. if (Request.HttpMethod == "GET" && !(Request.RawUrl.Contains(".axd")))
  7. {
  8. string LowercaseURL = HttpContext.Current.Request.RawUrl.ToString().ToLower();
  9. Response.Clear();
  10. Response.Status = "301 Moved Permanently";
  11. Response.AddHeader("Location", LowercaseURL);
  12. Response.End();
  13. }
  14. }
  15. }
Add Comment
Please, Sign In to add comment