簡體   English   中英

如何在沒有“另存為”對話框的情況下從 ASP.NET 下載帶有 Responce 對象的文件?

[英]How to download a file with Responce object from ASP.NET without "Save as " Dialog?

你好朋友,我在 C# 中有這個代碼:

        Response.ContentType = "Application/x-msexcel";
        Response.AppendHeader("Content-Disposition", "attachment; filename=excel.xlsx");
        Response.TransmitFile(@"C:\excel.xlsx"); first option
        //Response.WriteFile(@"C:\excel.xlsx");  second option
        //Response.Write(@"C:\excel.xlsx");  thirdoption

執行這些行后,我可以下載文件,但我不想看到“另存為”對話框窗口,只需自動下載文件。

可以從瀏覽器“詢問與否”修改此配置,但想法是自動進行,這可能嗎?

非常感謝!

不,不是。 是瀏覽器的安全選項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM