I would like to generate an ICS file (iCalendar) in my ASP.NET application and then open it automatically without showing the file dialog "Open / Save / Cancel".
This generated file would be opened by the user's default application for these ics files.
I tried this :
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();
I tried other headers like Content-Type : application/outlook
or Content-Disposition : attachment;
instead of Content-Disposition : inline;
.... without success.
This code works to open the ICS through the dialog. But i would to open it automatically without showing this dialog.
How this could be done ?
You can't do that. The user's browser settings determine whether they'll see a save dialog or whether it saves directly and opens.
Imagine if it hypothetically worked as you want it to - that'd be a huge security vulnerability.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.