示例#1
0
        public static void RenderRss(IEnumerable <RssItem> rssItems = null, string rssTitle = "", string rssDescription = "", string rssLink = "")
        {
            if (rssItems == null)
            {
                rssItems = MediaDetailsMapper.GetRssItems(MediaDetailsMapper.GetAllChildMediaDetails(FrameworkSettings.Current.CurrentMedia.ID, FrameworkSettings.Current.CurrentLanguage.ID).Where(i => i.CanRender && i.MediaType.ShowInSiteTree).OrderByDescending(i => i.PublishDate));
            }

            if (rssLink == "")
            {
                if (FrameworkSettings.Current.CurrentMediaDetail != null)
                {
                    rssLink = URIHelper.ConvertToAbsUrl(FrameworkSettings.Current.CurrentMediaDetail.VirtualPath);
                }
                else
                {
                    rssLink = URIHelper.ConvertToAbsUrl(URIHelper.GetCurrentVirtualPath());
                }
            }

            if (rssTitle == "")
            {
                rssTitle = FrameworkSettings.Current.CurrentMediaDetail.Title;
            }

            if (rssDescription == "")
            {
                rssDescription = FrameworkSettings.Current.CurrentMediaDetail.GetMetaDescription();
            }

            Rss rss = new Rss(rssTitle, rssLink, rssDescription);

            rss.Items = rssItems;

            var Response = HttpContext.Current.Response;

            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType     = "text/xml";

            RssHelper.WriteRss(rss, Response.OutputStream);

            Response.Flush();
            Response.End();
        }