public override void ExecuteResult(System.Web.Mvc.ControllerContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (this.JsonRequestBehavior == System.Web.Mvc.JsonRequestBehavior.DenyGet && string.Equals(context.HttpContext.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException("JSON GET is not allowed"); } System.Web.HttpResponseBase response = context.HttpContext.Response; response.ContentType = string.IsNullOrEmpty(this.ContentType) ? "application/json" : this.ContentType; if (this.ContentEncoding != null) { response.ContentEncoding = this.ContentEncoding; } if (this.Data == null) { return; } var scriptSerializer = Newtonsoft.Json.JsonSerializer.Create(this.Settings); using (var sw = new System.IO.StringWriter()) { scriptSerializer.Serialize(sw, this.Data); response.Write(sw.ToString()); } }
protected override void WriteFile(System.Web.HttpResponseBase response) { var result = "<?xml version='1.0' encoding='utf-8'?>"; result += "<rss xmlns:a10='http://www.w3.org/2005/Atom' version='2.0'>"; result += "<channel>"; result += "<title>Upcoming Nerd Dinners</title>"; result += "<link>" + currentUrl + "</link>"; result += "<description>Upcoming Nerd Dinners</description>"; foreach (var d in Dinners) { var content = ""; content += d.Description; content += " with "; content += d.HostedBy; content += " on "; content += d.EventDate.ToString("MMM dd, yyyy"); content += " at "; content += d.EventDate.ToShortTimeString(); content += ". Where: "; content += d.Address; content += ", "; content += d.Country; result += "<item>"; result += "<guid isPermaLink='true'>http://nrddnr.com/" + d.DinnerID + "</guid>"; result += "<link>http://nrddnr.com/" + d.DinnerID + "</link>"; result += "<title>" + d.Title + "</title>"; result += "<description>" + content + "</description>"; result += "<pubDate>" + d.EventDate.ToUniversalTime() + "</pubDate>"; result += "<a10:updated>" + d.EventDate.ToUniversalTime() + "</a10:updated>"; result += "<a10:content type='text'>" + content + "</a10:content>"; result += "</item>"; } result += "</channel>"; result += "</rss>"; response.Write(result); }
protected override void WriteFile(System.Web.HttpResponseBase response) { iCalendar iCal = new iCalendar(); foreach (Dinner d in this.Dinners) { try { Event e = CalendarHelpers.DinnerToEvent(d, iCal); iCal.Events.Add(e); } catch (ArgumentOutOfRangeException) { //Swallow folks that have dinners in 9999. } } iCalendarSerializer serializer = new iCalendarSerializer(iCal); string result = serializer.SerializeToString(); response.ContentEncoding = Encoding.UTF8; response.Write(result); }
internal void AppendNewLine(System.Web.HttpResponseBase respose) { respose.Write("<br/>"); }