I do not necessarily have to use response.redirect, but that is what I had. I would like to open the selected link in a new window. How do I do that?
context.Response.Redirect(ConfigurationManager.AppSettings["URL"] + ext );
If you use target="_blank" only to open links in a new tab, then it is vulnerable to an attacker. When you open a link in a new tab ( target="_blank" ), the page that opens in a new tab can access the initial tab and change its location using the window.
Response. Redirect sends an HTTP request to the browser, then the browser sends that request to the web server, then the web server delivers a response to the web browser. For example, suppose you are on the web page "UserRegister. aspx" page and it has a button that redirects you to the "UserDetail.
For instance, instead of a "form" button that causes a postback and redirect, you could use a LinkButton that will behave like a hyperlink, allowing the browser to request the new page directly.
Response. Redirect("Default. aspx", true) means current page execution is terminated and page is redirected to the default.
You can't is the short answer. The browser is the only thing that can open up a new window.
What you can do is send a chunk of html down the response that has a link with your url as an href, target="_blank" and a chunk of javascript onload of the form that fakes a click. If this doesn't work then use a window.open(url);
response.write("<script>");
response.write("window.open('page.html','_blank')");
response.write("</script>");
You're trying to accomplish a client-side task from the server side, so you'll need to do a bit of hacking.
One option is sending back a page that's just a bit of JavaScript, which then will handle the redirect.
This isn't particularly clean, but what about:
Response.Write("<script>window.open('http://www.somesite.com/','_blank');</script>");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With