我有一個頁面上的一個asp.net超鏈接點擊後會打開一個新的窗口,一個新的頁面:ASP.NET Response.AddHeader關閉窗口
lnkPrint.NavigateUrl = blah blah;
lnkPrint.Target = "_blank";
在這個新的頁面是創建一個用戶控件Word文檔與OpenXML。我正在嘗試向用戶展示Word文檔,而不關閉新窗口。但是,該窗口只是向用戶呈現文檔,並關閉窗口並返回到帶有超鏈接的頁面。
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + masterFileName);
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.TransmitFile(masterContainer);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
有誰知道爲什麼新窗口正在關閉以及如何讓它保持打開狀態?
感謝,
是不是因爲'HttpContext.Current.Response.Close();' – ErikMes
是的,我試着把最後兩行,但它似乎沒有幫助 – UKGirl
我不明白這裏的問題...如果您的瀏覽是按照您的描述進行的,頁面應該在新窗口/選項卡中打開。也許我誤解了一些東西? –