2016-03-02 79 views
0

在瀏覽local.com/test/document,我想重定向到local.com/document/demo.pdf重定向爲.pdf

是越來越正確重定向。即demo.pdf文件正在下載。但瀏覽器網址沒有改變。

我使用下列重定向代碼行:

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

這是因爲我們重定向到文件的正確的行爲?或者有沒有一種方法可以下載文件,並且瀏覽器url被更改?

回答

0

使用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>