I have the following code from my global.asax Application_BeginRequest method which looks for a possible SEO page name with an id and rewrites the url. This has been working just fine for a couple of years now. Recently I was asked to add a utm_source parameter to the page/querystring that is translated. I started with a url like "seo_page_J1234.aspx?utm_source=abc123" and that wouldn't work but when I changed it to "seo_page_J1234.aspx&utm_source=abc123" it worked fine when I'd run it locally. When I push it to our live server I get "The page cannot be displayed because an internal server error has occurred."
I've checked the event viewer and don't see any errors listed. I've also tried wrapping all of my code in try/catches and outputting the error to the page but I still get the generic error message. So, I have two questions, does anyone know what might cause it to work locally and not remotely and secondly, is there a setting that's keeping the error from making it into the event viewer? Locally I'm running win 7 pro and remotely it's win server 2008 sp2 w/ IIS7. If I take off the utm_source parameter the page loads fine.
protected void Application_BeginRequest(object sender, EventArgs e) { string strCurrentPath = Request.Path.ToLower();
if (strCurrentPath.IndexOf(".aspx") > -1)
{
if (!File.Exists(Request.PhysicalPath))
{
string startStr = Request.RawUrl;
string utm_source = string.Empty;
if (startStr.Contains("&utm_source="))
{
utm_source = "&utm_source=" + startStr.Substring(startStr.IndexOf("&utm_source=") + 12);
startStr = startStr.Substring(0, startStr.IndexOf("&utm_source="));
}
//look up possible redirect
string s = URLRewriter.Translate(startStr);
if (s.Length > 0)
HttpContext.Current.RewritePath(s + utm_source);
else
Response.Redirect("~/404Err.aspx");
}
}
}