private void createVideoSyndicationFeed() { //Create syndicated feed var myFeed = new SyndicationFeed(); myFeed.Title = TextSyndicationContent.CreatePlaintextContent(user.CompanyName); myFeed.Description = TextSyndicationContent.CreatePlaintextContent("Video Podcast RSS FEED"); myFeed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri("https://versolstore.blob.core.windows.net/" + user.CompanyName.ToLower() + "devstoreaccount1/videos/rss.xml"))); myFeed.Links.Add(SyndicationLink.CreateSelfLink(new Uri("https://versolstore.blob.core.windows.net/" + user.CompanyName.ToLower() + "devstoreaccount1/videos/rss.xml"))); myFeed.Copyright = TextSyndicationContent.CreatePlaintextContent("All rights reserved"); myFeed.Language = "en-us"; //Return the feed's xml content as the response MemoryStream ms = new MemoryStream(); XmlWriter feedWriter = XmlWriter.Create(ms); Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(myFeed); rssFormatter.WriteTo(feedWriter); feedWriter.Close(); var container = client.GetContainerReference(user.CompanyName.ToLower()); var blob = container.GetBlockBlobReference("videos/video.rss"); blob.UploadFromByteArray(ms.ToArray(), 0, ms.ToArray().Length); ms.Close(); }
public SyndicationFeedFormatter GetProcesses(string format) { IEnumerable <Process> processes = new List <Process>(Process.GetProcesses()); //SyndicationFeed also has convenience constructors //that take in common elements like Title and Content. SyndicationFeed f = new SyndicationFeed(); f.LastUpdatedTime = DateTimeOffset.Now; f.Title = SyndicationContent.CreatePlaintextContent("Currently running processes"); f.Links.Add(SyndicationLink.CreateSelfLink(OperationContext.Current.IncomingMessageHeaders.To)); f.Items = from p in processes select new SyndicationItem() { LastUpdatedTime = DateTimeOffset.Now, Title = SyndicationContent.CreatePlaintextContent(p.ProcessName), Summary = SyndicationContent.CreateHtmlContent(String.Format("<b>{0}</b>", p.MainWindowTitle)), Content = SyndicationContent.CreateXmlContent(new ProcessData(p)) }; // Choose a formatter according to the query string passed. if (format == "rss") { return(new Rss20FeedFormatter(f)); } else { return(new Atom10FeedFormatter(f)); } }
public static string GetSyndicationFeed(this IEnumerable <Notification> notifications, string contentType) { var feed = new SyndicationFeed("System notification", "Publishes system notifications", new Uri("http://localhost")); feed.Authors.Add(new SyndicationPerson("*****@*****.**", "Testor Testorsson", "http://localhost")); feed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(HttpContext.Current.Request.Url.AbsoluteUri), "application/atom+xml")); feed.Items = notifications.ASyndicationItems(feed); var stringWriter = new StringWriter(); XmlWriter feedWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings { OmitXmlDeclaration = true }); feed.Copyright = SyndicationContent.CreatePlaintextContent("Copyright hygia"); feed.Language = "en-us"; if (contentType == ContentTypes.Atom) { feed.SaveAsAtom10(feedWriter); } else { feed.SaveAsRss20(feedWriter); } feedWriter.Close(); return(stringWriter.ToString()); }
public void CreateSelfLink() { SyndicationLink link = SyndicationLink.CreateSelfLink(null); Assert.IsNull(link.Uri, "#1"); Assert.IsNull(link.MediaType, "#2"); Assert.AreEqual("self", link.RelationshipType, "#3"); }
/// <summary> /// Initializes a new instance of the <see cref="YafSyndicationFeed" /> class. /// </summary> /// <param name="subTitle">The sub title.</param> /// <param name="feedType">The feed source.</param> /// <param name="sf">The feed type Atom/RSS.</param> /// <param name="urlAlphaNum">The alphanumerically encoded base site Url.</param> public YafSyndicationFeed([NotNull] string subTitle, YafRssFeeds feedType, int sf, [NotNull] string urlAlphaNum) { this.Copyright = new TextSyndicationContent( "Copyright {0} {1}".FormatWith(DateTime.Now.Year, YafContext.Current.BoardSettings.Name)); this.Description = new TextSyndicationContent( "{0} - {1}".FormatWith( YafContext.Current.BoardSettings.Name, sf == YafSyndicationFormats.Atom.ToInt() ? YafContext.Current.Get <ILocalization>().GetText("ATOMFEED") : YafContext.Current.Get <ILocalization>().GetText("RSSFEED"))); this.Title = new TextSyndicationContent( "{0} - {1} - {2}".FormatWith( sf == YafSyndicationFormats.Atom.ToInt() ? YafContext.Current.Get <ILocalization>().GetText("ATOMFEED") : YafContext.Current.Get <ILocalization>().GetText("RSSFEED"), YafContext.Current.BoardSettings.Name, subTitle)); // Alternate link this.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(BaseUrlBuilder.BaseUrl))); // Self Link var slink = new Uri( YafBuildLink.GetLinkNotEscaped(ForumPages.rsstopic, true, "pg={0}&ft={1}".FormatWith(feedType.ToInt(), sf))); this.Links.Add(SyndicationLink.CreateSelfLink(slink)); this.Generator = "YetAnotherForum.NET"; this.LastUpdatedTime = DateTime.UtcNow; this.Language = YafContext.Current.Get <ILocalization>().LanguageCode; this.ImageUrl = new Uri("{0}/YAFLogo.png".FormatWith(Path.Combine(YafForumInfo.ForumBaseUrl, YafBoardFolders.Current.Images))); this.Id = "urn:{0}:{1}:{2}:{3}:{4}".FormatWith( urlAlphaNum, sf == YafSyndicationFormats.Atom.ToInt() ? YafContext.Current.Get <ILocalization>().GetText("ATOMFEED") : YafContext.Current.Get <ILocalization>().GetText("RSSFEED"), YafContext.Current.BoardSettings.Name, subTitle, YafContext.Current.PageBoardID).Unidecode(); this.Id = this.Id.Replace(" ", string.Empty); // this.Id = "urn:uuid:{0}".FormatWith(Guid.NewGuid().ToString("D")); this.BaseUri = slink; this.Authors.Add( new SyndicationPerson(YafContext.Current.BoardSettings.ForumEmail, "Forum Admin", BaseUrlBuilder.BaseUrl)); this.Categories.Add(new SyndicationCategory(FeedCategories)); // writer.WriteRaw("<?xml-stylesheet type=\"text/xsl\" href=\"" + YafForumInfo.ForumClientFileRoot + "rss.xsl\" media=\"screen\"?>"); }
private static void AddChannelLinks(HttpContextBase httpContext, SyndicationFeed feed) { // Improved interoperability with feed readers by implementing atom:link with rel="self" if (httpContext.Request.Url == null) return; var baseUrl = new UriBuilder(httpContext.Request.Url.Scheme, httpContext.Request.Url.Host).Uri; var feedLink = new Uri(baseUrl, httpContext.Request.RawUrl); feed.Links.Add(SyndicationLink.CreateSelfLink(feedLink)); feed.Links.Add(new SyndicationLink { Uri = baseUrl, RelationshipType = "alternate" }); }
private static void AddChannelLinks(HttpRequestBase request, SyndicationFeed feed) { var baseUrl = new UriBuilder(request.Url.Scheme, request.Url.Host).Uri; var link = new Uri(baseUrl, request.RawUrl); feed.Links.Add(SyndicationLink.CreateSelfLink(link)); feed.Links.Add(new SyndicationLink { Uri = baseUrl, RelationshipType = "alternate" }); }
public static void AddSelfLink(this SyndicationFeed feed, Uri uri) { if (feed == null) { throw new ArgumentNullException("feed"); } if (uri == null) { throw new ArgumentNullException("uri"); } feed.Links.Add(SyndicationLink.CreateSelfLink(uri, ContentTypes.Atom)); }
public void DisplayRss(HttpListenerContext context, string subUrl) { feed.Links.Clear(); feed.Links.Add(SyndicationLink.CreateSelfLink(context.Request.Url));//.BaseUri = context.Request.Url; using (StreamWriter writer = new StreamWriter(context.Response.OutputStream)) { XmlWriter xmlWriter = XmlWriter.Create(writer); feed.SaveAsAtom10(xmlWriter); xmlWriter.Close(); context.Response.Close(); } }
public void CreateSelfLink_Uri_String_ReturnsExpected(Uri uri, string mediaType) { SyndicationLink link = SyndicationLink.CreateSelfLink(uri, mediaType); Assert.Empty(link.AttributeExtensions); Assert.Null(link.BaseUri); Assert.Empty(link.ElementExtensions); Assert.Equal(0, link.Length); Assert.Equal(mediaType, link.MediaType); Assert.Equal("self", link.RelationshipType); Assert.Null(link.Title); Assert.Same(uri, link.Uri); }
protected SyndicationLink GetSelfLink(string collection, int pageNumber) { Uri feedUri; if (pageNumber == 0) { feedUri = allEntriesTemplate.BindByPosition(this.webOperationContext.BaseUri, collection); } else { feedUri = pagedEntriesTemplate.BindByPosition(this.webOperationContext.BaseUri, collection, pageNumber.ToString(CultureInfo.InvariantCulture)); } return(SyndicationLink.CreateSelfLink(feedUri, ContentTypes.Atom)); }
static SyndicationLink GetSelfLink(string collection, int pageNumber) { Uri feedUri; if (pageNumber == 0) { feedUri = allEntriesTemplate.BindByPosition(WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BaseUri, collection); } else { feedUri = pagedEntriesTemplate.BindByPosition(WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BaseUri, collection, pageNumber.ToString(CultureInfo.InvariantCulture)); } return(SyndicationLink.CreateSelfLink(feedUri, ContentTypes.Atom)); }
/// <summary> /// Gets the feed containing meta data about the feed and the feed entries. /// </summary> /// <returns>A <see cref="SyndicationFeed"/>.</returns> public SyndicationFeed GetFeed() { SyndicationFeed feed = new SyndicationFeed() { // id (Required) - The feed universally unique identifier. Id = FeedId, // title (Required) - Contains a human readable title for the feed. Often the same as the title of the associated website. This value should not be blank. Title = SyndicationContent.CreatePlaintextContent("ASP.NET MVC Boilerplate"), // items (Required) - The items to add to the feed. Items = this.GetItems(), // subtitle (Recommended) - Contains a human-readable description or subtitle for the feed. Description = SyndicationContent.CreatePlaintextContent("This is the ASP.NET MVC Boilerplate feed description."), // updated (Optional) - Indicates the last time the feed was modified in a significant way. LastUpdatedTime = DateTimeOffset.Now, // logo (Optional) - Identifies a larger image which provides visual identification for the feed. Images should be twice as wide as they are tall. ImageUrl = new Uri(this.urlHelper.AbsoluteContent("~/content/icons/atom-logo-96x48.png")), // rights (Optional) - Conveys information about rights, e.g. copyrights, held in and over the feed. Copyright = new TextSyndicationContent(string.Format("© {0} - {0}", DateTime.Now.Year, Application.Name)), // lang (Optional) - The language of the feed. Language = "en-GB", // generator (Optional) - Identifies the software used to generate the feed, for debugging and other purposes. Do not put in anything that identifies the technology you are using. // Generator = "Sample Code", // base (Buggy) - Add the full base URL to the site so that all other links can be relative. This is great, except some feed readers are buggy with it, INCLUDING FIREFOX!!! (See https://bugzilla.mozilla.org/show_bug.cgi?id=480600). // BaseUri = new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetIndex)) }; // self link (Required) - The URL for the syndication feed. feed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetFeed)), ContentType.Atom)); // alternate link (Recommended) - The URL for the web page showing the same data as the syndication feed. feed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetIndex)), ContentType.Html)); // author (Recommended) - Names one author of the feed. A feed may have multiple author elements. A feed must contain at least one author element unless all of the entry elements contain at least one author element. feed.Authors.Add(this.GetPerson()); // category (Optional) - Specifies a category that the feed belongs to. A feed may have multiple category elements. feed.Categories.Add(new SyndicationCategory("CategoryName")); // contributor (Optional) - Names one contributor to the feed. An feed may have multiple contributor elements. feed.Contributors.Add(this.GetPerson()); // icon (Optional) - Identifies a small image which provides iconic visual identification for the feed. Icons should be square. feed.SetIcon(this.urlHelper.AbsoluteContent("~/content/icons/atom-icon-48x48.png")); // Add the Yahoo Media namespace (xmlns:media="http://search.yahoo.com/mrss/") to the Atom feed. // This gives us extra abilities, like the ability to give thumbnail images to entries. See http://www.rssboard.org/media-rss for more information. feed.AddYahooMediaNamespace(); return(feed); }
public SyndicationFeed CreateFeed(IPortalContext portal, HttpContext context, string selfRouteName, int maximumItems) { if (portal == null) { throw new ArgumentNullException("portal"); } if (context == null) { throw new ArgumentNullException("context"); } var blog = _dataAdapter.Select(); if (blog == null) { throw new InvalidOperationException("Blog not found."); } var posts = _dataAdapter.SelectPosts(0, maximumItems).ToArray(); var feedLastUpdatedTime = posts.Any() ? new DateTimeOffset(posts.First().PublishDate) : DateTimeOffset.UtcNow; var blogHtmlUri = new Uri(context.Request.Url, blog.ApplicationPath.AbsolutePath); var feed = new SyndicationFeed(posts.Select(p => GetFeedItem(p, context))) { Id = "uuid:{0};{1}".FormatWith(blog.Id, feedLastUpdatedTime.Ticks), Title = SyndicationContent.CreatePlaintextContent(blog.Title), Description = SyndicationContent.CreateHtmlContent(blog.Summary.ToString()), LastUpdatedTime = feedLastUpdatedTime, BaseUri = new Uri(context.Request.Url, "/") }; var selfPath = RouteTable.Routes.GetVirtualPath(context.Request.RequestContext, selfRouteName, new RouteValueDictionary { { "__portalScopeId__", portal.Website.Id }, { "id", blog.Id } }); if (selfPath != null) { feed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(context.Request.Url, ApplicationPath.FromPartialPath(selfPath.VirtualPath).AbsolutePath), "application/atom+xml")); } feed.Links.Add(SyndicationLink.CreateAlternateLink(blogHtmlUri, "text/html")); return(feed); }
private List <SyndicationItem> GetRecentPagesOrPosts(RSSFeedInclude feedData) { List <SyndicationItem> syndRSS = new List <SyndicationItem>(); List <SiteNav> lst = new List <SiteNav>(); ContentPageType PageType = new ContentPageType(); using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) { if (feedData == RSSFeedInclude.PageOnly || feedData == RSSFeedInclude.BlogAndPages) { List <SiteNav> lst1 = navHelper.GetLatest(this.SiteID, 8, true); lst = lst.Union(lst1).ToList(); List <SiteNav> lst2 = navHelper.GetLatestUpdates(this.SiteID, 10, true); lst = lst.Union(lst2).ToList(); } if (feedData == RSSFeedInclude.BlogOnly || feedData == RSSFeedInclude.BlogAndPages) { List <SiteNav> lst1 = navHelper.GetLatestPosts(this.SiteID, 8, true); lst = lst.Union(lst1).ToList(); List <SiteNav> lst2 = navHelper.GetLatestPostUpdates(this.SiteID, 10, true); lst = lst.Union(lst2).ToList(); } } lst.RemoveAll(x => x.ShowInSiteMap == false && x.ContentType == ContentPageType.PageType.ContentEntry); lst.RemoveAll(x => x.BlockIndex == true); foreach (SiteNav sn in lst) { SyndicationItem si = new SyndicationItem(); string sPageURI = RemoveDupeSlashesURL(this.ConstructedCanonicalURL(sn)); Uri PageURI = new Uri(sPageURI); si.Content = new TextSyndicationContent(sn.PageTextPlainSummaryMedium.ToString()); si.Title = new TextSyndicationContent(sn.NavMenuText); si.Links.Add(SyndicationLink.CreateSelfLink(PageURI)); si.AddPermalink(PageURI); si.LastUpdatedTime = sn.EditDate; si.PublishDate = sn.CreateDate; syndRSS.Add(si); } return(syndRSS.OrderByDescending(p => p.PublishDate).ToList()); }
/// <summary> /// Gets the feed containing meta data about the feed and the feed entries. /// </summary> /// <param name="cancellationToken">A <see cref="CancellationToken"/> signifying if the request is cancelled.</param> /// <returns>A <see cref="SyndicationFeed"/>.</returns> public async Task <SyndicationFeed> GetFeed(CancellationToken cancellationToken) { SyndicationFeed feed = new SyndicationFeed() { // id (Required) - The feed universally unique identifier. Id = FeedId, // title (Required) - Contains a human readable title for the feed. Often the same as the title of the // associated website. This value should not be blank. Title = SyndicationContent.CreatePlaintextContent("Моє місто - про Київ цікаво"), // items (Required) - The items to add to the feed. Items = await GetItems(cancellationToken), // subtitle (Recommended) - Contains a human-readable description or subtitle for the feed. Description = SyndicationContent.CreatePlaintextContent("Київські новини та аналітика, повна афіша Києва, сервіси для киян"), // updated (Optional) - Indicates the last time the feed was modified in a significant way. LastUpdatedTime = DateTimeOffset.Now, Language = "uk-UA", }; // self link (Required) - The URL for the syndication feed. feed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(FeedUrl), "Rss")); // alternate link (Recommended) - The URL for the web page showing the same data as the syndication feed. //feed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(SiteUrl), "Html")); // hub link (Recommended) - The URL for the PubSubHubbub hub. Used to push new entries to subscribers // instead of making them poll the feed. See feed updated method below. feed.Links.Add(new SyndicationLink(new Uri(PubSubHubbubHubUrl), "hub", null, null, 0)); // author (Recommended) - Names one author of the feed. A feed may have multiple author elements. A feed // must contain at least one author element unless all of the entry elements contain // at least one author element. feed.Authors.Add(GetPerson()); // category (Optional) - Specifies a category that the feed belongs to. A feed may have multiple category // elements. feed.Categories.Add(new SyndicationCategory("Новини")); // contributor (Optional) - Names one contributor to the feed. An feed may have multiple contributor // elements. feed.Contributors.Add(GetPerson()); return(feed); }
public SyndicationFeed CreateSyndicationFeed(string nickname, string feedType, string scheme, string host) { IList <Post> posts = _postRepository.GetBlogPosts(nickname); Blog blog = _blogRepository.GetBlog(nickname); string url = string.Format("{0}://{1}/{2}", scheme, host, nickname); var feed = new SyndicationFeed(blog.Title, blog.Description, new Uri(url), url, blog.LastUpdated); feed.Authors.Add(new SyndicationPerson { Name = blog.User.Name }); feed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(url + "/feed/" + feedType))); var items = new List <SyndicationItem>(); foreach (Post post in posts) { var htmlurl = string.Format("{0}://{1}/{2}/{3}/{4}/{5}/{6}", scheme, host, nickname, post.Posted.Year, post.Posted.Month, post.Posted.Day, post.TitleLink); var item = new SyndicationItem(); item.Title = new TextSyndicationContent(post.Title, TextSyndicationContentKind.Html); item.Content = new TextSyndicationContent(post.BlogPost, TextSyndicationContentKind.Html); item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(htmlurl), "text/html")); var editurl = string.Format("{0}://{1}/{2}/pub/atom/{3}", scheme, host, nickname, post.Id); item.Links.Add(SyndicationLink.CreateSelfLink(new Uri(editurl))); item.Links.Add(new SyndicationLink { RelationshipType = "edit", Uri = new Uri(editurl), MediaType = "application/atom+xml;type=entry" }); item.PublishDate = post.Edited; item.Id = editurl; items.Add(item); } feed.Items = items; return(feed); }
/// <summary> /// Initializes a new instance of the <see cref="YafSyndicationFeed" /> class. /// </summary> /// <param name="subTitle">The sub title.</param> /// <param name="feedType">The feed source.</param> /// <param name="sf">The feed type Atom/RSS.</param> /// <param name="urlAlphaNum">The alphanumerically encoded base site Url.</param> public YafSyndicationFeed([NotNull] string subTitle, YafRssFeeds feedType, int sf, [NotNull] string urlAlphaNum) { this.Copyright = new TextSyndicationContent($"Copyright {DateTime.Now.Year} {YafContext.Current.BoardSettings.Name}"); this.Description = new TextSyndicationContent( $"{YafContext.Current.BoardSettings.Name} - {(sf == YafSyndicationFormats.Atom.ToInt() ? YafContext.Current.Get<ILocalization>().GetText("ATOMFEED") : YafContext.Current.Get<ILocalization>().GetText("RSSFEED"))}"); this.Title = new TextSyndicationContent( $"{(sf == YafSyndicationFormats.Atom.ToInt() ? YafContext.Current.Get<ILocalization>().GetText("ATOMFEED") : YafContext.Current.Get<ILocalization>().GetText("RSSFEED"))} - {YafContext.Current.BoardSettings.Name} - {subTitle}"); // Alternate link this.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(BaseUrlBuilder.BaseUrl))); // Self Link var slink = new Uri( BuildLink.GetLinkNotEscaped(ForumPages.rsstopic, true, $"pg={feedType.ToInt()}&ft={sf}")); this.Links.Add(SyndicationLink.CreateSelfLink(slink)); this.Generator = "YetAnotherForum.NET"; this.LastUpdatedTime = DateTime.UtcNow; this.Language = YafContext.Current.Get <ILocalization>().LanguageCode; this.ImageUrl = new Uri( $"{BaseUrlBuilder.BaseUrl}{BoardInfo.ForumClientFileRoot}{BoardFolders.Current.Logos}/{YafContext.Current.BoardSettings.ForumLogo}"); this.Id = $"urn:{urlAlphaNum}:{(sf == YafSyndicationFormats.Atom.ToInt() ? YafContext.Current.Get<ILocalization>().GetText("ATOMFEED") : YafContext.Current.Get<ILocalization>().GetText("RSSFEED"))}:{YafContext.Current.BoardSettings.Name}:{subTitle}:{YafContext.Current.PageBoardID}" .Unidecode(); this.Id = this.Id.Replace(" ", string.Empty); // this.Id = "urn:uuid:{0}".FormatWith(Guid.NewGuid().ToString("D")); this.BaseUri = slink; this.Authors.Add( new SyndicationPerson( YafContext.Current.BoardSettings.ForumEmail, "Forum Admin", BaseUrlBuilder.BaseUrl)); this.Categories.Add(new SyndicationCategory(FeedCategories)); }
/// <summary> /// Initializes a new instance of the <see cref="FeedItem"/> class. /// </summary> /// <param name="subTitle"> /// The sub title. /// </param> /// <param name="feedType"> /// The feed source. /// </param> /// <param name="urlAlphaNum"> /// The alphanumerically encoded base site Url. /// </param> public FeedItem([NotNull] string subTitle, RssFeeds feedType, string urlAlphaNum) { this.Copyright = new TextSyndicationContent( $"Copyright {DateTime.Now.Year} {BoardContext.Current.BoardSettings.Name}"); this.Description = new TextSyndicationContent( $"{BoardContext.Current.BoardSettings.Name} - {BoardContext.Current.Get<ILocalization>().GetText("ATOMFEED")}"); this.Title = new TextSyndicationContent( $"{BoardContext.Current.Get<ILocalization>().GetText("ATOMFEED")} - {BoardContext.Current.BoardSettings.Name} - {subTitle}"); // Alternate link this.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(BaseUrlBuilder.BaseUrl))); // Self Link var slink = new Uri( BoardContext.Current.Get <LinkBuilder>().GetLink(ForumPages.Feed, true, $"feed={feedType.ToInt()}")); this.Links.Add(SyndicationLink.CreateSelfLink(slink)); this.Generator = "YetAnotherForum.NET"; this.LastUpdatedTime = DateTime.UtcNow; this.Language = BoardContext.Current.Get <ILocalization>().LanguageCode; this.ImageUrl = new Uri( $"{BaseUrlBuilder.BaseUrl}{BoardInfo.ForumClientFileRoot}{BoardContext.Current.Get<BoardFolders>().Logos}/{BoardContext.Current.BoardSettings.ForumLogo}"); this.Id = $"urn:{urlAlphaNum}:{BoardContext.Current.Get<ILocalization>().GetText("ATOMFEED")}:{BoardContext.Current.BoardSettings.Name}:{subTitle}:{BoardContext.Current.PageBoardID}" .Unidecode(); this.Id = this.Id.Replace(" ", string.Empty); this.BaseUri = slink; this.Authors.Add( new SyndicationPerson( BoardContext.Current.BoardSettings.ForumEmail, "Forum Admin", BaseUrlBuilder.BaseUrl)); this.Categories.Add(new SyndicationCategory(FeedCategories)); }
/// <summary> /// Gets the feed containing meta data about the feed and the feed entries. /// </summary> /// <param name="cancellationToken">A <see cref="CancellationToken"/> signifying if the request is cancelled.</param> /// <returns>A <see cref="SyndicationFeed"/>.</returns> public async Task <SyndicationFeed> GetFeed(CancellationToken cancellationToken) { SyndicationFeed feed = new SyndicationFeed() { // id (Required) - The feed universally unique identifier. Id = FeedId, // title (Required) - Contains a human readable title for the feed. Often the same as the title of the // associated website. This value should not be blank. Title = SyndicationContent.CreatePlaintextContent("ASP.NET MVC Boilerplate"), // items (Required) - The items to add to the feed. Items = await this.GetItems(cancellationToken), // subtitle (Recommended) - Contains a human-readable description or subtitle for the feed. Description = SyndicationContent.CreatePlaintextContent( "This is the ASP.NET MVC Boilerplate feed description."), // updated (Optional) - Indicates the last time the feed was modified in a significant way. LastUpdatedTime = DateTimeOffset.Now, // logo (Optional) - Identifies a larger image which provides visual identification for the feed. // Images should be twice as wide as they are tall. ImageUrl = new Uri(this.urlHelper.AbsoluteContent("~/content/icons/atom-logo-96x48.png")), // rights (Optional) - Conveys information about rights, e.g. copyrights, held in and over the feed. Copyright = SyndicationContent.CreatePlaintextContent( string.Format("© {0} - {1}", DateTime.Now.Year, Application.Name)), // lang (Optional) - The language of the feed. Language = "en-GB", // generator (Optional) - Identifies the software used to generate the feed, for debugging and other // purposes. Do not put in anything that identifies the technology you are using. // Generator = "Sample Code", // base (Buggy) - Add the full base URL to the site so that all other links can be relative. This is // great, except some feed readers are buggy with it, INCLUDING FIREFOX!!! // (See https://bugzilla.mozilla.org/show_bug.cgi?id=480600). // BaseUri = new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetIndex)) }; // self link (Required) - The URL for the syndication feed. feed.Links.Add(SyndicationLink.CreateSelfLink( new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetFeed)), ContentType.Atom)); // alternate link (Recommended) - The URL for the web page showing the same data as the syndication feed. feed.Links.Add(SyndicationLink.CreateAlternateLink( new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetIndex)), ContentType.Html)); // hub link (Recommended) - The URL for the PubSubHubbub hub. Used to push new entries to subscribers // instead of making them poll the feed. See feed updated method below. feed.Links.Add(new SyndicationLink(new Uri(PubSubHubbubHubUrl), "hub", null, null, 0)); // first, last, next previous (Optional) - Atom 1.0 supports paging of your feed. This is good if your feed // becomes very large and needs splitting up into pages. To add // paging, you must add links to the first, last, next and previous // feed pages. // feed.Links.Add(new SyndicationLink(new Uri("http://example.com/feed"), "first", null, null, 0)); // feed.Links.Add(new SyndicationLink(new Uri("http://example.com/feed?page=10"), "last", null, null, 0)); // if ([HAS_PREVIOUS_PAGE]) // feed.Links.Add(new SyndicationLink(new Uri("http://example.com/feed?page=1")), "previous", null, null, 0)); // if ([HAS_NEXT_PAGE]) // feed.Links.Add(new SyndicationLink(new Uri("http://example.com/feed?page=3"), "next", null, null, 0)); // author (Recommended) - Names one author of the feed. A feed may have multiple author elements. A feed // must contain at least one author element unless all of the entry elements contain // at least one author element. feed.Authors.Add(this.GetPerson()); // category (Optional) - Specifies a category that the feed belongs to. A feed may have multiple category // elements. feed.Categories.Add(new SyndicationCategory("CategoryName")); // contributor (Optional) - Names one contributor to the feed. An feed may have multiple contributor // elements. feed.Contributors.Add(this.GetPerson()); // icon (Optional) - Identifies a small image which provides iconic visual identification for the feed. // Icons should be square. feed.SetIcon(this.urlHelper.AbsoluteContent("~/content/icons/atom-icon-48x48.png")); // Add the Yahoo Media namespace (xmlns:media="http://search.yahoo.com/mrss/") to the Atom feed. // This gives us extra abilities, like the ability to give thumbnail images to entries. // See http://www.rssboard.org/media-rss for more information. feed.AddYahooMediaNamespace(); return(feed); }
protected void Page_Load(object sender, EventArgs e) { ContentQuery contentQuery = new ContentQuery { ContentTypeID = (int)SueetieContentType.BlogPost, CacheMinutes = 5, SueetieContentViewTypeID = (int)SueetieContentViewType.AggregateBlogPostList }; List <SueetieBlogPost> sueetieBlogPosts = SueetieBlogs.GetSueetieBlogPostList(contentQuery); var dataItems = from post in sueetieBlogPosts orderby post.DateCreated descending select post; const int maxItemsInFeed = 10; // Determine whether we're outputting an Atom or RSS feed bool outputAtom = (Request.QueryString["Type"] == "ATOM"); bool outputRss = !outputAtom; if (outputRss) { Response.ContentType = "application/rss+xml"; } else if (outputAtom) { Response.ContentType = "application/atom+xml"; } // Create the feed and specify the feed's attributes SyndicationFeed myFeed = new SyndicationFeed(); myFeed.Title = TextSyndicationContent.CreatePlaintextContent("Most Recent Posts on " + SiteSettings.Instance.SiteName); myFeed.Description = TextSyndicationContent.CreatePlaintextContent("A syndication of the most recently published posts on " + SiteSettings.Instance.SiteName); myFeed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(GetFullyQualifiedUrl("~/Default.aspx")))); myFeed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(GetFullyQualifiedUrl(Request.RawUrl)))); myFeed.Copyright = TextSyndicationContent.CreatePlaintextContent("Copyright " + SiteSettings.Instance.SiteName); myFeed.Language = "en-us"; List <SyndicationItem> feedItems = new List <SyndicationItem>(); foreach (SueetieBlogPost p in dataItems.Take(maxItemsInFeed)) { if (outputAtom && p.Author == null) { continue; } SyndicationItem item = new SyndicationItem(); item.Title = TextSyndicationContent.CreatePlaintextContent(p.BlogTitle + " - " + p.Title); item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(GetFullyQualifiedUrl(p.Permalink)))); item.Summary = TextSyndicationContent.CreateHtmlContent(p.PostContent); item.Categories.Add(new SyndicationCategory(p.BlogTitle)); item.PublishDate = p.DateCreated; item.Id = GetFullyQualifiedUrl(p.Permalink); SyndicationPerson authInfo = new SyndicationPerson(); authInfo.Email = p.Email; authInfo.Name = p.DisplayName; item.Authors.Add(authInfo); feedItems.Add(item); } myFeed.Items = feedItems; XmlWriterSettings outputSettings = new XmlWriterSettings(); outputSettings.Indent = true; XmlWriter feedWriter = XmlWriter.Create(Response.OutputStream, outputSettings); if (outputAtom) { Atom10FeedFormatter atomFormatter = new Atom10FeedFormatter(myFeed); atomFormatter.WriteTo(feedWriter); } else if (outputRss) { Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(myFeed); rssFormatter.WriteTo(feedWriter); } feedWriter.Close(); }
public HttpResponseMessage GetBlog(string id, HttpRequestMessage request) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); try { IBlogsService blogsService = ObjectFactory.GetInstance <IBlogsService>(); var blog = blogsService.Get(String.Format("blogs/{0}", id)); var etag = request.Headers.IfNoneMatch.FirstOrDefault(); if (etag != null && etag.Tag == blog.etag) { response.StatusCode = HttpStatusCode.NotModified; } else { if (blog != null) { if (this.ClientAcceptsMediaType("text/html", request)) { response.Content = new ObjectContent <string>(blog.ToHtml(), "text/html"); } else { SyndicationFeed blogFeed = new SyndicationFeed { Title = new TextSyndicationContent("Single Blog"), LastUpdatedTime = new DateTimeOffset(DateTime.Now) }; blogFeed.Links.Add(SyndicationLink.CreateSelfLink(request.RequestUri)); SyndicationItem item = new SyndicationItem(); List <SyndicationItem> itemList = new List <SyndicationItem> { item }; blogFeed.Items = itemList; item.Id = blog.Id; item.LastUpdatedTime = blog.updated; item.PublishDate = blog.published; item.Title = new TextSyndicationContent(blog.name); item.Summary = new TextSyndicationContent(blog.description); item.Links.Add(SyndicationLink.CreateSelfLink(request.RequestUri)); item.Links.Add(SyndicationLink.CreateAlternateLink(request.RequestUri, "text/html")); item.Links.Add(new SyndicationLink(new Uri(String.Format("{0}/{1}", this.serviceURI, blog.Id)), "edit", "Edit blog", "application/atom+xml;type=feed", 0)); item.Links.Add(new SyndicationLink(new Uri(String.Format("{0}/{1}/posts", this.serviceURI, blog.Id)), "posts", "Blog posts", "application/atom+xml;type=feed", 0)); item.Authors.Add(new SyndicationPerson(string.Empty, blog.author, string.Empty)); SyndicationFeedFormatter formatter = null; if (this.ClientAcceptsMediaType("application/atom+xml", request)) { formatter = blogFeed.GetAtom10Formatter(); } else { if (this.ClientAcceptsMediaType("application/rss+xml", request)) { formatter = blogFeed.GetRss20Formatter(); } } response.Content = new ObjectContent(typeof(SyndicationFeedFormatter), formatter); } } else { response.StatusCode = HttpStatusCode.NotFound; } } } catch (Exception) { response.StatusCode = HttpStatusCode.InternalServerError; } return(response); }
public HttpResponseMessage GetBlogTagCloud(string id, HttpRequestMessage request) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); try { IBlogsService blogsService = ObjectFactory.GetInstance <IBlogsService>(); var blog = blogsService.Get(String.Format("blogs/{0}", id)); var tagCloud = blogsService.GetTagCloud(String.Format("blogs/{0}", id)); if (blog != null) { SyndicationFeed blogFeed = new SyndicationFeed { Title = new TextSyndicationContent("Blog tag cloud"), LastUpdatedTime = new DateTimeOffset(DateTime.Now) }; blogFeed.Links.Add(SyndicationLink.CreateSelfLink(request.RequestUri)); SyndicationItem item = new SyndicationItem(); List <SyndicationItem> itemList = new List <SyndicationItem> { item }; blogFeed.Items = itemList; item.Id = blog.Id; item.LastUpdatedTime = blog.updated; item.PublishDate = blog.published; item.Title = new TextSyndicationContent("Blog tag cloud"); item.Content = SyndicationContent.CreatePlaintextContent(BuildtagCloud(tagCloud)); item.Links.Add(SyndicationLink.CreateSelfLink(request.RequestUri)); SyndicationFeedFormatter formatter = null; if (this.ClientAcceptsMediaType("application/atom+xml", request)) { formatter = blogFeed.GetAtom10Formatter(); } else { if (this.ClientAcceptsMediaType("application/rss+xml", request)) { formatter = blogFeed.GetRss20Formatter(); } } response.Content = new ObjectContent(typeof(SyndicationFeedFormatter), formatter); } else { response.StatusCode = HttpStatusCode.NotFound; } } catch (Exception) { response.StatusCode = HttpStatusCode.InternalServerError; } return(response); }
public static void Snippet7() { // <Snippet7> SyndicationLink link = SyndicationLink.CreateSelfLink(new Uri("http://server/link")); // </Snippet7> }
public static void Snippet8() { // <Snippet8> SyndicationLink link = SyndicationLink.CreateSelfLink(new Uri("http://server/link"), "text/html"); // </Snippet8> }
public HttpResponseMessage GetBlogs(HttpRequestMessage request, int pageIndex = 1, int pageSize = 10) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); try { IBlogsService blogsService = ObjectFactory.GetInstance <IBlogsService>(); List <Blog> blogs = blogsService.GetAll(pageIndex, pageSize); if (blogs != null) { if (this.ClientAcceptsMediaType("text/html", request)) { var blogsHtml = blogs.GenerateBlogsHtml(); response.Content = new ObjectContent <string>(blogsHtml, "text/html"); } else { SyndicationFeed blogsFeed = new SyndicationFeed { Title = new TextSyndicationContent("Blogs List"), LastUpdatedTime = new DateTimeOffset(DateTime.Now) }; blogsFeed.Links.Add(SyndicationLink.CreateSelfLink(request.RequestUri)); List <SyndicationItem> itemList = new List <SyndicationItem>(); blogsFeed.Items = itemList; foreach (var blog in blogs) { SyndicationItem item = new SyndicationItem { Id = blog.Id, LastUpdatedTime = blog.updated, PublishDate = blog.published, Title = new TextSyndicationContent(blog.name), Summary = new TextSyndicationContent(blog.description) }; item.Links.Add(SyndicationLink.CreateSelfLink(new Uri(String.Format("{0}/{1}", this.serviceURI, blog.Id)))); item.Links.Add(SyndicationLink.CreateAlternateLink(request.RequestUri, "text/html")); item.Links.Add(new SyndicationLink(new Uri(String.Format("{0}/{1}", this.serviceURI, blog.Id)), "service.edit", "Edit Blog", "application/atom+xml;type=feed", 0)); item.Links.Add(new SyndicationLink(new Uri(String.Format("{0}/{1}/posts", this.serviceURI, blog.Id)), "service.posts", "Blog posts", "application/atom+xml;type=feed", 0)); var pagingLinks = this.BuildPagingLinks(blogsService.Count(), pageIndex, pageSize, request.RequestUri); foreach (var link in pagingLinks) { item.Links.Add(link); } item.Authors.Add(new SyndicationPerson(string.Empty, blog.author, string.Empty)); itemList.Add(item); } SyndicationFeedFormatter formatter = null; if (this.ClientAcceptsMediaType("application/atom+xml", request)) { formatter = blogsFeed.GetAtom10Formatter(); } else { if (this.ClientAcceptsMediaType("application/rss+xml", request)) { formatter = blogsFeed.GetRss20Formatter(); } } response.Content = new ObjectContent(typeof(SyndicationFeedFormatter), formatter); } } else { response.StatusCode = HttpStatusCode.NoContent; } } catch (Exception) { response.StatusCode = HttpStatusCode.InternalServerError; } return(response); }
public HttpResponseMessage GetComments(string blogId, string postId, HttpRequestMessage request, int pageIndex = 1, int pageSize = 10) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); try { ICommentsService commentsService = ObjectFactory.GetInstance <ICommentsService>(); var comments = commentsService.GetAllFromPost(String.Format("posts/{0}", postId), pageIndex, pageSize); if (comments != null) { if (this.ClientAcceptsMediaType("text/html", request)) { var commentsHtml = comments.GenerateCommentsHtml(); response.Content = new ObjectContent <string>(commentsHtml, "text/html"); } else { SyndicationFeed postCommentsFeed = new SyndicationFeed { Title = new TextSyndicationContent( String.Format("Post {0} comments", postId)), LastUpdatedTime = new DateTimeOffset(DateTime.Now) }; postCommentsFeed.Links.Add(SyndicationLink.CreateSelfLink(request.RequestUri)); List <SyndicationItem> itemList = new List <SyndicationItem>(); postCommentsFeed.Items = itemList; foreach (var comment in comments) { SyndicationItem item = new SyndicationItem { Id = comment.Id, LastUpdatedTime = comment.updated, PublishDate = comment.published }; item.Links.Add(SyndicationLink.CreateSelfLink(new Uri(String.Format("{0}/blogs/{1}/posts/{2}/{3}", this.serviceURI, blogId, postId, comment.Id)))); item.Links.Add(SyndicationLink.CreateAlternateLink(request.RequestUri, "text/html")); item.Links.Add(new SyndicationLink(new Uri(String.Format("{0}/blogs/{1}/posts/{2}", this.serviceURI, blogId, postId)), "service.post", "Parent post", "application/atom+xml;type=feed", 0)); item.Links.Add(new SyndicationLink(new Uri(String.Format("{0}/blogs/{1}/posts/{2}/{3}", this.serviceURI, blogId, postId, comment.Id)), "service.edit", "Edit comment", "application/atom+xml;type=feed", 0)); var pagingLinks = this.BuildPagingLinks(commentsService.Count(), pageIndex, pageSize, request.RequestUri); foreach (var link in pagingLinks) { item.Links.Add(link); } item.Authors.Add(new SyndicationPerson(string.Empty, comment.author, string.Empty)); item.Content = SyndicationContent.CreatePlaintextContent(comment.content); itemList.Add(item); } SyndicationFeedFormatter formatter = null; if (this.ClientAcceptsMediaType("application/atom+xml", request)) { formatter = postCommentsFeed.GetAtom10Formatter(); } else { if (this.ClientAcceptsMediaType("application/rss+xml", request)) { formatter = postCommentsFeed.GetRss20Formatter(); } } response.Content = new ObjectContent(typeof(SyndicationFeedFormatter), formatter); } } else { response.StatusCode = HttpStatusCode.NoContent; } } catch (Exception) { response.StatusCode = HttpStatusCode.InternalServerError; } return(response); }
internal SyndicationFeed CreateUpdateFeed(UpdateFeedModel feedModel, Uri currentUri, UrlHelper urlHelper) { var updateFeed = new SyndicationFeed { Id = string.Format("tag:{0},{1:yyyy-MM-dd}:feed/utc-time/{1:HH:mm:ss}", currentUri.Host, feedModel.LastUpdateUtcDateTimeOffset), Language = "en", Title = SyndicationContent.CreatePlaintextContent("IT Training Manager"), Description = SyndicationContent.CreatePlaintextContent("New Courses"), LastUpdatedTime = feedModel.LastUpdateUtcDateTimeOffset, Links = { SyndicationLink.CreateSelfLink(currentUri, "application/atom+xml"), SyndicationLink.CreateAlternateLink(new UriBuilder { Scheme = currentUri.Scheme, Host = currentUri.Host, Port= currentUri.Port }.Uri, "text/html") }, Items = feedModel.Courses.Select(item => { var syndicationItem = new SyndicationItem { Id = item.GetCourseUri(urlHelper, currentUri.Scheme).ToString(), Title = SyndicationContent.CreatePlaintextContent(item.CourseTitle), Content = SyndicationContent.CreateHtmlContent(item.CourseDescription), Links = { SyndicationLink.CreateAlternateLink(item.GetCourseUri(urlHelper, currentUri.Scheme), "text/html") }, PublishDate = item.PublishedUtcDateOffset, LastUpdatedTime = feedModel.LastUpdateUtcDateTimeOffset, Categories = { new SyndicationCategory { Label = "/" + item.CategoryTitle, Name = item.CategoryTitle, Scheme = item.GetCategoryUriString(urlHelper, currentUri.Scheme) } } }; foreach (var person in item.Authors) { syndicationItem.Authors.Add(new SyndicationPerson { Name = person.Title, Uri = item.GetPersonUriString(person.UrlName, urlHelper, currentUri.Scheme) }); } foreach (var person in item.CoAuthors) { syndicationItem.Contributors.Add(new SyndicationPerson { Name = person.Title, Uri = item.GetPersonUriString(person.UrlName, urlHelper, currentUri.Scheme) }); } return(syndicationItem); }) }; return(updateFeed); }
public HttpResponseMessage GetComment(string blogId, string postId, string id, HttpRequestMessage request) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); try { ICommentsService commentsService = ObjectFactory.GetInstance <ICommentsService>(); var comment = commentsService.Get(String.Format("comments/{0}", id)); var etag = request.Headers.IfNoneMatch.FirstOrDefault(); if (etag != null && etag.Tag == comment.etag) { response.StatusCode = HttpStatusCode.NotModified; } else { if (comment != null) { if (this.ClientAcceptsMediaType("text/html", request)) { response.Content = new ObjectContent <string>(comment.ToHtml(), "text/html"); } else { SyndicationFeed commentFeed = new SyndicationFeed { Title = new TextSyndicationContent("Single Comment"), LastUpdatedTime = new DateTimeOffset(DateTime.Now) }; commentFeed.Links.Add(SyndicationLink.CreateSelfLink(request.RequestUri)); SyndicationItem item = new SyndicationItem(); List <SyndicationItem> itemList = new List <SyndicationItem> { item }; commentFeed.Items = itemList; item.Id = comment.Id; item.LastUpdatedTime = comment.updated; item.PublishDate = comment.published; item.Content = new TextSyndicationContent(comment.content); item.Links.Add(SyndicationLink.CreateSelfLink(request.RequestUri)); item.Links.Add(SyndicationLink.CreateAlternateLink(request.RequestUri, "text/html")); item.Links.Add(new SyndicationLink(request.RequestUri, "service.edit", "Edit Comment", "application/atom+xml;type=feed", 0)); item.Links.Add(new SyndicationLink(new Uri(String.Format("{0}/blogs/{1}/posts/{2}/{3}", this.serviceURI, blogId, postId, comment.Id)), "service.comments", "Post comments", "application/atom+xml;type=feed", 0)); item.Links.Add(new SyndicationLink(new Uri(String.Format("{0}/blogs/{1}/posts/{2}", this.serviceURI, blogId, postId)), "service.post", "Parent post", "application/atom+xml;type=feed", 0)); item.Authors.Add(new SyndicationPerson(string.Empty, comment.author, string.Empty)); SyndicationFeedFormatter formatter = null; if (this.ClientAcceptsMediaType("application/atom+xml", request)) { formatter = commentFeed.GetAtom10Formatter(); } else { if (this.ClientAcceptsMediaType("application/rss+xml", request)) { formatter = commentFeed.GetRss20Formatter(); } } response.Content = new ObjectContent(typeof(SyndicationFeedFormatter), formatter); } } else { response.StatusCode = HttpStatusCode.NotFound; } } } catch (Exception) { response.StatusCode = HttpStatusCode.InternalServerError; } return(response); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { var channelId = 0; // Determine the maximum number of items to show in the feed if (Request.QueryString["pid"] != null) { _projectId = Convert.ToInt32(Request.Params["pid"]); } //get feed id if (Request.QueryString["channel"] != null) { channelId = Convert.ToInt32(Request.Params["channel"]); } if (!User.Identity.IsAuthenticated && _projectId == 0) { throw new HttpException(403, "Access Denied"); } if (_projectId != 0) { //Security Checks if (!User.Identity.IsAuthenticated && ProjectManager.GetById(_projectId).AccessType == ProjectAccessType.Private) { throw new HttpException(403, "Access Denied"); } if (User.Identity.IsAuthenticated && ProjectManager.GetById(_projectId).AccessType == ProjectAccessType.Private && !ProjectManager.IsUserProjectMember(User.Identity.Name, _projectId)) { throw new HttpException(403, "Access Denied"); } } // Determine whether we're outputting an Atom or RSS feed var outputRss = (Request.QueryString["Type"] == "RSS"); var outputAtom = !outputRss; // Output the appropriate ContentType Response.ContentType = outputRss ? "application/rss+xml" : "application/atom+xml"; // Create the feed and specify the feed's attributes var myFeed = new SyndicationFeed(); myFeed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(GetFullyQualifiedUrl("~/Default.aspx")))); myFeed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(GetFullyQualifiedUrl(Request.RawUrl)))); myFeed.Language = "en-us"; switch (channelId) { case 1: MilestoneFeed(ref myFeed); break; case 2: CategoryFeed(ref myFeed); break; case 3: StatusFeed(ref myFeed); break; case 4: PriorityFeed(ref myFeed); break; case 5: TypeFeed(ref myFeed); break; case 6: AssigneeFeed(ref myFeed); break; case 7: FilteredIssuesFeed(ref myFeed); break; case 8: RelevantFeed(ref myFeed); break; case 9: AssignedFeed(ref myFeed); break; case 10: OwnedFeed(ref myFeed); break; case 11: CreatedFeed(ref myFeed); break; case 12: AllIssuesFeed(ref myFeed); break; case 13: QueryFeed(ref myFeed); break; case 14: OpenIssueFeed(ref myFeed); break; case 15: MonitoredFeed(ref myFeed); break; case 16: ClosedFeed(ref myFeed); break; } // Return the feed's XML content as the response var outputSettings = new XmlWriterSettings { Indent = true }; //(Uncomment for readability during testing) var feedWriter = XmlWriter.Create(Response.OutputStream, outputSettings); if (outputAtom) { // Use Atom 1.0 var atomFormatter = new Atom10FeedFormatter(myFeed); atomFormatter.WriteTo(feedWriter); } else { // Emit RSS 2.0 var rssFormatter = new Rss20FeedFormatter(myFeed); rssFormatter.WriteTo(feedWriter); } feedWriter.Close(); }