I am trying to write SEO friendly URL for my website. i am using global.asax.
protected void Ap
But When the regular expression matches, the code goes on infinite loop. When I apply debugger in this code, It moves infinitely when the regular expression Matches.
This is the code that I have used
protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext incoming = HttpContext.Current;
string oldpath = incoming.Request.Path;
string imgId = string.Empty;
// string imgName = string.Empty;
Regex regex = new Regex(@"N/(.+)", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
MatchCollection matches = regex.Matches(oldpath);
if (matches.Count > 0)
{
imgId = matches[0].Groups[1].ToString();
// imgName = matches[0].Groups[2].ToString();
string newPath = String.Concat("~/inner.aspx?Id=", imgId);
incoming.RewritePath(String.Concat("~/inner.aspx?Id=", imgId), false);
}
}