Tutorial :executing script ASP.NET application


In my ASP.NET application default page is Login.aspx.
In this page I check the Query string, if it is empty I load the page, but if query string has parameters I want to launch the application on client.
This is working when first I browse my application without parameters (http://localhost/myApps), and then browse the application with some parameters (http://localhost/myApps?ID='test').
But if I directly browse the site with http://localhost/myApps?ID='test', it is not working.

Following is the code of my Global.asax page

public class Global : System.Web.HttpApplication  {      protected void Application_BeginRequest(object sender, EventArgs e)      {          System.Web.HttpContext httpCurrent;          httpCurrent = System.Web.HttpContext.Current;          string  currentURL;          if (Request.QueryString.Count == 4)          {              string PID = Request.QueryString["PID"].ToString();              string sid = Request.QueryString["acc_no"].ToString();              string uid = Request.QueryString["userID"].ToString();              string uname = Request.QueryString["username"].ToString();              currentURL = "ViewImages.aspx?PID=" + PID + "&acc_no=" + sid + "&userID=" + uid + "&username=" + uname;              httpCurrent.RewritePath(currentURL);          }          else          {              currentURL = "Login.aspx?";              httpCurrent.RewritePath(currentURL);          }      }  }  


Did a quick sample app and following worked for me

 protected void Application_BeginRequest(object sender, EventArgs e)      {      HttpContext c = HttpContext.Current;      if (Request.QueryString.Count > 0)         c.RewritePath("form2.aspx");      else          c.RewritePath("form1.aspx");      }  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »