Url Problem in Global.ascx File - TechRepublic
Question
May 20, 2010 at 07:27 AM
amjadhussain

Url Problem in Global.ascx File

by amjadhussain . Updated 16 years, 1 month ago

My live site Url is http://www.Amjad.com and when i am using this url like http://test.Amjad.com and Page redirect to login page http://www.Amjad.com/Admin/Login.aspx?URL=test please send me the code of this process

I have already write some code but its create problem
protected void Application_BeginRequest(object sender, EventArgs e)
{
//if (!Request.CurrentExecutionFilePath.EndsWith(“.aspx”)) return;
//if (!Request.CurrentExecutionFilePath.EndsWith(“/”)) return;

string strURL = HttpContext.Current.Request.Url.AbsoluteUri.ToString();
//try
//{
//string strURL = System.IO.Path.GetFullPath(Request.PhysicalPath);
Response.Write(strURL);
Regex rewrite_regex = new Regex(@”(.+)\/((.+)\.aspx)”, RegexOptions.IgnoreCase);
MatchCollection match_rewrite = rewrite_regex.Matches(strURL);
if (match_rewrite.Count < 1) { string ur = strURL.Substring(strURL.LastIndexOf("/") + 1); HttpContext.Current.Response.Redirect("http://www.Amjad.com/Admin/Login.aspx?URL=" + ur); //HttpContext.Current.Response.Redirect("http://www.clock.ie/Admin/Login.aspx?URL=" + ur.ToString()); // HttpContext.Current.Response.Redirect("http://localhost:1618/ClockSpot/Admin/Login.aspx?URL=" + ur.ToString()); //Context.RewritePath("http://www.clock.ie/Admin/Login.aspx?URL=" + ur.ToString()); //string ur1 = strURL.Substring(strURL.LastIndexOf("//") + 2); //Response.Write(ur1); //string[] s = ur1.Split('.'); //if (s[0] != "www") //{ // HttpContext.Current.Response.Redirect("http://www.clock.ie/Admin/Login.aspx?URL=" + s[0].ToString()); //} }

This discussion is locked

All Comments