using System.Text.RegularExpressions;
using System.Collections.Generic;
namespace HelloWorldMvcApp
public class HomeController : Controller
public ActionResult Index()
return View(new SampleViewModel());
public ActionResult GetCalendarFile()
var sb = new StringBuilder();
sb.AppendLine("BEGIN:VCALENDAR");
sb.AppendLine("VERSION: 2.0");
sb.AppendLine("PRODID:-//hacksw/handcal//NONSGML v1.0//EN");
sb.AppendLine("METHOD:PUBLISH");
sb.AppendLine("BEGIN:VEVENT");
sb.AppendLine("DTSTART:20160615T070000Z");
sb.AppendLine("DTEND:20160615T090000Z");
sb.AppendLine("LOCATION:Test");
sb.AppendLine("UID:dbecc21e-bb16-494f-adef-2ba9520f1379");
sb.AppendLine("DTSTAMP:20160623T105226Z");
sb.AppendLine("SUMMARY:Test");
sb.AppendLine("DESCRIPTION:Test");
sb.AppendLine("PRIORITY:5");
sb.AppendLine("CLASS:PUBLIC");
sb.AppendLine("END:VEVENT");
sb.AppendLine("END:VCALENDAR");
var cd = new System.Net.Mime.ContentDisposition
var buffer = Encoding.UTF8.GetBytes(sb.ToString());
Response.AppendHeader("Content-Disposition", cd.ToString());
return File(buffer, "text/calendar");
public virtual FileResult GetCalendarFile2()
var sb = new StringBuilder();
sb.AppendLine("BEGIN:VCALENDAR");
sb.AppendLine("VERSION: 2.0");
sb.AppendLine("METHOD:PUBLISH");
sb.AppendLine("BEGIN:VEVENT");
sb.AppendLine("DTSTART:20160615T070000Z");
sb.AppendLine("DTEND:20160615T090000Z");
sb.AppendLine("LOCATION:Test");
sb.AppendLine("UID:dbecc21e-bb16-494f-adef-2ba9520f1379");
sb.AppendLine("DTSTAMP:20160623T105226Z");
sb.AppendLine("SUMMARY:Test");
sb.AppendLine("DESCRIPTION:Test");
sb.AppendLine("PRIORITY:5");
sb.AppendLine("CLASS:PUBLIC");
sb.AppendLine("END:VEVENT");
sb.AppendLine("BEGIN:VEVENT");
sb.AppendLine("DTSTART:20160616T070000Z");
sb.AppendLine("DTEND:20160616T090000Z");
sb.AppendLine("LOCATION:Test");
sb.AppendLine("UID:81ed08a2-1629-455e-b889-76e3ba3d5840");
sb.AppendLine("DTSTAMP:20160623T105226Z");
sb.AppendLine("SUMMARY:Test");
sb.AppendLine("DESCRIPTION:Test");
sb.AppendLine("PRIORITY:5");
sb.AppendLine("CLASS:PUBLIC");
sb.AppendLine("END:VEVENT");
sb.AppendLine("BEGIN:VEVENT");
sb.AppendLine("DTSTART:20160617T070000Z");
sb.AppendLine("DTEND:20160617T090000Z");
sb.AppendLine("LOCATION:Test");
sb.AppendLine("UID:b77df895-01be-4159-b9d2-1536928411a3");
sb.AppendLine("DTSTAMP:20160623T105226Z");
sb.AppendLine("SUMMARY:Test");
sb.AppendLine("DESCRIPTION:Test");
sb.AppendLine("PRIORITY:5");
sb.AppendLine("CLASS:PUBLIC");
sb.AppendLine("END:VEVENT");
sb.AppendLine("BEGIN:VEVENT");
sb.AppendLine("DTSTART:20160618T070000Z");
sb.AppendLine("DTEND:20160618T090000Z");
sb.AppendLine("LOCATION:Test");
sb.AppendLine("UID:9822f33f-7fb0-4ba4-84b0-5f475f4213cd");
sb.AppendLine("DTSTAMP:20160623T105226Z");
sb.AppendLine("SUMMARY:Test");
sb.AppendLine("DESCRIPTION:Test");
sb.AppendLine("PRIORITY:5");
sb.AppendLine("CLASS:PUBLIC");
sb.AppendLine("END:VEVENT");
sb.AppendLine("BEGIN:VEVENT");
sb.AppendLine("DTSTART:20160619T070000Z");
sb.AppendLine("DTEND:20160619T090000Z");
sb.AppendLine("LOCATION:Test");
sb.AppendLine("UID:13baa7fb-fdd3-4fb5-b80a-d70dc1931eeb");
sb.AppendLine("DTSTAMP:20160623T105226Z");
sb.AppendLine("SUMMARY:Test");
sb.AppendLine("DESCRIPTION:Test");
sb.AppendLine("PRIORITY:5");
sb.AppendLine("CLASS:PUBLIC");
sb.AppendLine("END:VEVENT");
sb.AppendLine("BEGIN:VEVENT");
sb.AppendLine("DTSTART:20160620T070000Z");
sb.AppendLine("DTEND:20160620T090000Z");
sb.AppendLine("LOCATION:Test");
sb.AppendLine("UID:953dabf7-2265-4f66-a229-97254f1c0aa3");
sb.AppendLine("DTSTAMP:20160623T105226Z");
sb.AppendLine("SUMMARY:Test");
sb.AppendLine("DESCRIPTION:Test");
sb.AppendLine("PRIORITY:5");
sb.AppendLine("CLASS:PUBLIC");
sb.AppendLine("END:VEVENT");
sb.AppendLine("BEGIN:VEVENT");
sb.AppendLine("DTSTART:20160621T070000Z");
sb.AppendLine("DTEND:20160621T090000Z");
sb.AppendLine("LOCATION:Test");
sb.AppendLine("UID:c2cc1ead-3dc4-4194-9e4d-62771a46b29c");
sb.AppendLine("DTSTAMP:20160623T105226Z");
sb.AppendLine("SUMMARY:Test");
sb.AppendLine("DESCRIPTION:Test");
sb.AppendLine("PRIORITY:5");
sb.AppendLine("CLASS:PUBLIC");
sb.AppendLine("END:VEVENT");
sb.AppendLine("BEGIN:VEVENT");
sb.AppendLine("DTSTART:20160622T070000Z");
sb.AppendLine("DTEND:20160622T090000Z");
sb.AppendLine("LOCATION:Test");
sb.AppendLine("UID:04b24907-4948-4506-b525-cf2f26cdf622");
sb.AppendLine("DTSTAMP:20160623T105226Z");
sb.AppendLine("SUMMARY:Test");
sb.AppendLine("DESCRIPTION:Test");
sb.AppendLine("PRIORITY:5");
sb.AppendLine("CLASS:PUBLIC");
sb.AppendLine("END:VEVENT");
sb.AppendLine("BEGIN:VEVENT");
sb.AppendLine("DTSTART:20160623T070000Z");
sb.AppendLine("DTEND:20160623T090000Z");
sb.AppendLine("LOCATION:Test");
sb.AppendLine("UID:2896b3dd-42aa-4bb3-ad60-816afb58b120");
sb.AppendLine("DTSTAMP:20160623T105226Z");
sb.AppendLine("SUMMARY:Test");
sb.AppendLine("DESCRIPTION:Test");
sb.AppendLine("PRIORITY:5");
sb.AppendLine("CLASS:PUBLIC");
sb.AppendLine("END:VEVENT");
sb.AppendLine("END:VCALENDAR");
var cd = new System.Net.Mime.ContentDisposition
var buffer = Encoding.UTF8.GetBytes(sb.ToString());
return File(buffer, "text/calendar", cd.FileName);