Pieczarr Pieczarr - 3 months ago 261
ASP.NET (C#) Question

How to open new tab before redirect

In my ASP project I need to open a new tab before redirecting website to a new address.

To open a new tab I use:

Context.Response.Write("<script> language='javascript'>window.open('google.com','_newtab');</script>");


which works like a charm until I add lines for redirect:

Response.Redirect(String.Format("~/CloseRequest.aspx?request_id={0}&returnURL={1}", RequestID, ReturnURL));


If I leave both lines the page will only redirect me to without opening a new tab.

How can I solve this?

Answer
    Context.Response.Write("<script language='javascript'>window.open('google.com','_newtab');
window.location.href='/CloseRequest.aspx?request_id="+RequestID+"&returnURL="+ReturnURL+"';</script>");