c# - 如何在 response.redirect 上使用 Target=_blank?

标签 c# asp.net .net

我不一定非要使用 response.redirect,但我就是这么用的。我想在新窗口中打开选定的链接。我该怎么做?

context.Response.Redirect(ConfigurationManager.AppSettings["URL"] + ext );

最佳答案

简短的回答是你不能。浏览器是唯一可以打开新窗口的东西。

您可以做的是将一段 html 发送到响应中,该响应包含与您的 url 的链接作为 href、target="_blank"和一大块伪造点击的 javascript onload 表单。如果这不起作用,则使用 window.open(url);

response.write("<script>");
response.write("window.open('page.html','_blank')");
response.write("</script>"); 

关于c# - 如何在 response.redirect 上使用 Target=_blank?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8994285/

相关文章:

c# - 如何缓存 XmlTextWriter 数据?

c# - 从构建输出运行单元测试

c# - 添加到 Observable 集合时的奇怪行为

c# - 您可以更改非事件表单的文本吗?

c# - 在 C# 中,为什么不能将条件运算符隐式转换为可为 null 的类型

c# - if else 语句简化以提高可读性

c# - 从车辆图像中提取车牌

asp.net - MVC 巨大模型性能不佳

c# - ASP.NET 无法更改 Formview 控件的可见性

c# - 如何在 C# 中使用 boolean 值