【问题标题】:Redirect to .pdf重定向到 .pdf
【发布时间】:2016-03-02 11:42:45
【问题描述】:

在浏览 local.com/test/document 时,我想重定向到 local.com/document/demo.pdf

它正在正确重定向。即 demo.pdf 文件正在下载。但是浏览器 URL 没有改变。

我正在使用以下代码行进行重定向:

HttpContext.Current.Response.Redirect("local.com/document/demo.pdf", false);
context.ApplicationInstance.CompleteRequest();

当我们重定向到文件时,这是正确的行为吗?或者有没有办法可以下载文件并更改浏览器网址?

【问题讨论】:

    标签: c# asp.net pdf redirect


    【解决方案1】:

    使用 Response.Redirect() 是不可能的,因为它是一个函数,一次只能完成一项任务。 你可以使用

    <a href="http://xyz.pdf" **target="_self"**>Click Me</a>
    Change the target _blank,it will redirect to a new tab.
    

    你也可以去

            <iframe src="xyz.pdf"></iframe>
    

    【讨论】:

      猜你喜欢
      • 2016-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-30
      相关资源
      最近更新 更多