2009-11-27 112 views
0

在我的ASP.NET应用程序的默认页面是Login.aspx。
在这个页面我检查查询字符串,如果它是空的我加载页面,但如果查询字符串有参数我想在客户端启动应用程序。
这是工作时,我第一次浏览我的应用程序没有参数(http://localhost/myApps),然后用一些参数(http://localhost/myApps?ID='test')浏览应用程序。
但如果我直接浏览网站http://localhost/myApps?ID='test',它不起作用。执行脚本ASP.NET应用程序

以下是我的Global.asax页

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); 
     } 
    } 
} 
+1

你能否提供更多细节?资源? – Anuraj 2009-11-27 10:36:55

+0

当用户浏览我的应用程序时没有任何参数我想显示默认页面,但是如果用户使用参数浏览应用程序我想运行一些服务器sode代码,不想显示默认页面? --Sital – Shital 2009-11-27 11:04:03

回答

0

的代码做了一个快速的示例应用程序,并按照我工作

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"); 
    } 
相关问题