2009-11-27 81 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"); 
    }