0
我想在我的ASP.NET應用程序中生成一個ICS文件(iCalendar),然後自動打開它而不顯示文件對話框「打開/保存/取消」。ASP.NET - 打開文件時不顯示對話框
此生成的文件將由用戶的這些ics文件的默認應用程序打開。
我嘗試這樣做:
String sICSPath = Server.MapPath(".") + @"\Files\Test.ics";
String sFullText = File.ReadAllText(sICSPath);
sFullText = sFullText.Replace("#NAME#", "MyName");
this.Response.ContentType = "Content-Type: text/Calendar";
this.Response.AddHeader("Cache-Control", "no-cache, must-revalidate");
this.Response.AddHeader("Pragma", "no-cache");
this.Response.AddHeader("Content-Disposition", "inline; filename=calendar.ics");
this.Response.Write(sFullText);
this.Response.End();
我試着像Content-Type : application/outlook
或Content-Disposition : attachment;
代替Content-Disposition : inline;
其他頭....沒有成功。
此代碼可用於通過對話框打開ICS。但是我會自動打開它而不顯示這個對話框。
這可以怎麼做?