簡體   English   中英

其他網站上的頁面重定向查詢字符串

[英]page redirection on other website with query string

我有一個網站“A”,我在其中登錄並重定向到頁面“A1”那里有一個文本框在填寫該代碼后要求輸入代碼有一個btn GO當我按下那個btn它重定向到頁面“A2”基於所有文本字段的輸入代碼都會填寫。 在那個頁面“A2”我有一個btn“SAVE&GO到網站B”

現在我想根據那個條目代碼,我想在保存的新瀏覽器中重定向到“網站B”,然后轉到網站B btn。

我正在使用該代碼

protected void btnSaveCase_Click(object sender, EventArgs e)
        {
           Session.Abandon();
           Response.Redirect(ConfigurationManager.AppSettings["website B"] + "/Content/CaseProps.aspx?CaseId=" + geturl(CaseId.ToString()));
          //Response.Redirect(ConfigurationManager.AppSettings["RCMS"], true);

        }

但它不起作用......

我可以使用其他一些代碼??

有人請幫助我......

你能試試這個:

Response.Redirect("URL", false);

Response.Redirect(ConfigurationManager.AppSettings["website B"] + "/Content/CaseProps.aspx?CaseId=" + geturl(CaseId.ToString()), false);

通過將其設置為false ,它將終止您當前的請求。

如果錯誤是重定向沒有帶您到網站B,那么很可能是因為您正在錯誤地將網站b存儲在AppSettings 請將網站B存儲為http://前綴,如下所示。

<add key="website B" value="http://www.websiteb.com"/>

好。 所以你想打開一個新窗口而不是重定向。 然后嘗試這個。

protected void btnSaveCase_Click(object sender, EventArgs e)
{
    try
    {
        Session.Abandon();
        string features = "menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes";
        string name = "mywindow";
        string url = String.Format("{0}/Content/CaseProps.aspx?CaseId={1}",
            ConfigurationManager.AppSettings["website B"],
            geturl(CaseId.ToString()));
        string script = String.Format(@"window.open('{0}','{1}','{2}');",
            url,
            name,
            features);
        ClientScript.RegisterStartupScript(typeof(Page), "key", script, true);
    }
    catch (System.Threading.ThreadAbortException)
    {
        throw;
    }
    catch (Exception ex)
    {
        throw new Exception(ex.Message);
    }
}

在不相關的附注中,在AppSettings使用WebsiteB而不是website B是一種很好的做法

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM