Latest Posts

Tuesday, October 21, 2014

URL Rewrite

void Application_BeginRequest(object sender, EventArgs e)
    {
        string URL_Path = Request.Path.ToLower();

        if (URL_Path.StartsWith("/news/"))
        {
            URL_Path = URL_Path.Trim('/');
            string NewsID = URL_Path.Substring(URL_Path.IndexOf("/"));
            HttpContext MyContext = HttpContext.Current;
            MyContext.RewritePath("/default.aspx?News=" + NewsID);
        }

    }