C# 使用查询字符串在其他网站上进行页面重定向

C# 使用查询字符串在其他网站上进行页面重定向,c#,.net,asp.net,visual-studio,query-string,C#,.net,Asp.net,Visual Studio,Query String,我有一个网站“a”,我在其中登录并重定向到页面“A1”,其中一个文本框在填写该代码后询问输入代码。当我按下该btn时,有一个btn转到页面“A2”,根据该输入代码,所有文本字段都被填充。在“A2”页面中,我有一个btn“保存并转到网站B” 现在,我想根据输入代码,在保存并转到网站B btn时,我想在新浏览器中重定向到“网站B” 我正在使用代码 protected void btnSaveCase_Click(object sender, EventArgs e) {

我有一个网站“a”,我在其中登录并重定向到页面“A1”,其中一个文本框在填写该代码后询问输入代码。当我按下该btn时,有一个btn转到页面“A2”,根据该输入代码,所有文本字段都被填充。在“A2”页面中,我有一个btn“保存并转到网站B”

现在,我想根据输入代码,在保存并转到网站B btn时,我想在新浏览器中重定向到“网站B”

我正在使用代码

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
中。请用
http://
这样的前缀存储网站B

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

另一个不相关的方面是,在
AppSettings

中使用
WebsiteB
而不是
WebsiteB
是一种很好的做法,它可以正常工作,但不能在新窗口中打开。我正在使用OnClientClick=“aspnetForm.target=”\u blank';如果您想打开另一个窗口,可以尝试类似的方法。Response.Write(“window.open('URL');”);我想在新窗口中打开网站B,你的代码能正常工作吗?Response.Redirect(ConfigurationManager.AppSettings[“网站B”]+”/Content/CaseProps.aspx?CaseId=“+CaseId.ToString());我无法用此实现相同的代码。请让我知道响应。写入(“window.open(ConfigurationManager.AppSettings[“RCMS”],true);”;这是我正在编写的代码您想打开一个新窗口吗?我想在我的btn点击时打开一个新的浏览器窗口,但我无法这样做。。。我的代码受保护无效btnSaveCase_Click(object sender,EventArgs e){Session.advand();Response.Redirect(ConfigurationManager.AppSettings[“RCMS”],true);}任何打开的内容请帮助我在新窗口中打开重定向我的url
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);
    }
}