简体   繁体   中英

page redirection on other website with query string

i have a website "A" in which i am login and redirecting to page "A1" there one text box is asking entry code after filling that code there is a btn GO when i press that btn its redirecting to page "A2" based on that entry code all text filed gets fill. in that page "A2" I have a btn "SAVE & GO to website B"

now wht i want to Based on that entry code i want to redirect to "website B" in new browser on save and go to website B btn.

i am using the code

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);

        }

but its not working...

can i use some other code??

anyone please help me...

Can you try this:

Response.Redirect("URL", false);

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

By setting it to false , it will terminate your current request.

If the error is that the redirect does not take you to website B then its most probably because you are storing the website b in AppSettings incorrectly. Please store the website B with http:// prefix like this.

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

Ok. So you want to open a new window rather than redirecting. Try this then.

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

On an unrelated side note, its a good practice to use WebsiteB instead of website B in AppSettings

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM