private AtomRoot GetAtomCore(string category, int maxDayCount, int maxEntryCount)
        {
            if (RedirectToFeedBurnerIfNeeded(category) == true)
            {
                return(null);
            }

            EntryCollection entries = null;

            //We only build the entries if blogcore doesn't exist and we'll need them later...
            if (dataService.GetLastEntryUpdate() == DateTime.MinValue)
            {
                entries = BuildEntries(category, maxDayCount, maxEntryCount);
            }

            //Try to get out as soon as possible with as little CPU as possible
            if (inASMX)
            {
                if (SiteUtilities.GetStatusNotModified(SiteUtilities.GetLatestModifedEntryDateTime(dataService, entries)))
                {
                    return(null);
                }
            }

            if (inASMX)
            {
                string referrer = Context.Request.UrlReferrer != null?Context.Request.UrlReferrer.AbsoluteUri:"";
                if (ReferralBlackList.IsBlockedReferrer(referrer))
                {
                    if (siteConfig.EnableReferralUrlBlackList404s)
                    {
                        return(null);
                    }
                }
                else
                {
                    loggingService.AddReferral(
                        new LogDataItem(
                            Context.Request.RawUrl,
                            referrer,
                            Context.Request.UserAgent,
                            Context.Request.UserHostName));
                }
            }


            //not-modified didn't work, do we have this in cache?
            string   CacheKey = "Atom:" + category + ":" + maxDayCount.ToString() + ":" + maxEntryCount.ToString();
            AtomRoot atomFeed = cache[CacheKey] as AtomRoot;

            if (atomFeed == null)             //we'll have to build it...
            {
                atomFeed = new AtomRoot();

                //However, if we made it this far, the not-modified check didn't work, and we may not have entries...
                if (entries == null)
                {
                    entries = BuildEntries(category, maxDayCount, maxEntryCount);
                }

                if (siteConfig.RssLanguage != null && siteConfig.RssLanguage.Length > 0)
                {
                    atomFeed.Lang = siteConfig.RssLanguage;
                }
                else                 //original default behavior of dasBlog
                {
                    atomFeed.Lang = "en-us";
                }

                if (category == null)
                {
                    atomFeed.Title = siteConfig.Title;
                }
                else
                {
                    atomFeed.Title = siteConfig.Title + " - " + category;
                }


                atomFeed.Tagline = siteConfig.Subtitle;
                atomFeed.Links.Add(new AtomLink(SiteUtilities.GetBaseUrl(siteConfig)));
                atomFeed.Links.Add(new AtomLink(SiteUtilities.GetAtomUrl(siteConfig), "self", null));
                atomFeed.Author = new AtomParticipant();
                // shouldn't we use the display name of an owner??
                atomFeed.Author.Name       = siteConfig.Copyright;
                atomFeed.Generator         = new AtomGenerator();
                atomFeed.Generator.Version = GetType().Assembly.GetName().Version.ToString();
                atomFeed.Icon = "favicon.ico";

                atomFeed.Id = SiteUtilities.GetBaseUrl(siteConfig);

                atomFeed.Logo = null;
                if (siteConfig.ChannelImageUrl != null && siteConfig.ChannelImageUrl.Trim().Length > 0)
                {
                    if (siteConfig.ChannelImageUrl.StartsWith("http"))
                    {
                        atomFeed.Logo = siteConfig.ChannelImageUrl;
                    }
                    else
                    {
                        atomFeed.Logo = SiteUtilities.RelativeToRoot(siteConfig, siteConfig.ChannelImageUrl);
                    }
                }


                DateTime feedModified = DateTime.MinValue;

                foreach (Entry entry in entries)
                {
                    if (entry.IsPublic == false || entry.Syndicated == false)
                    {
                        continue;
                    }

                    string entryLink = SiteUtilities.GetPermaLinkUrl(siteConfig, (ITitledEntry)entry);
                    string entryGuid = SiteUtilities.GetPermaLinkUrl(siteConfig, entry.EntryId);

                    AtomEntry atomEntry = new AtomEntry(entry.Title, new AtomLink(entryLink), entryGuid, entry.CreatedUtc, entry.ModifiedUtc);
                    //atomEntry.Created = entry.CreatedUtc; //not needed in 1.0
                    atomEntry.Summary = PreprocessItemContent(entry.EntryId, entry.Description);

                    // for multiuser blogs we want to be able to
                    // show the author per entry
                    User user = SiteSecurity.GetUser(entry.Author);
                    if (user != null)
                    {
                        // only the displayname
                        atomEntry.Author = new AtomParticipant()
                        {
                            Name = user.DisplayName
                        };
                    }

                    if (entry.Categories != null && entry.Categories.Length > 0)
                    {
                        if (atomEntry.Categories == null)
                        {
                            atomEntry.Categories = new AtomCategoryCollection();
                        }

                        string[] cats = entry.Categories.Split(';');
                        foreach (string c in cats)
                        {
                            AtomCategory cat = new AtomCategory();

                            //paulb: scheme should be a valid IRI, acsording to the spec
                            // (http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.category)
                            // so I changed this to the Category view for specified category. Now the feed validator likes us again ;-)
                            cat.Scheme = SiteUtilities.GetCategoryViewUrl(siteConfig, c);                               // "hierarchical";
                            // sub categories should be delimited using the path delimiter
                            string cleanCat = c.Replace('|', '/');
                            //Grab the first category, atom doesn't let us do otherwise!
                            cat.Term  = HttpUtility.HtmlEncode(cleanCat);
                            cat.Label = HttpUtility.HtmlEncode(cleanCat);
                            atomEntry.Categories.Add(cat);
                        }
                    }


                    // only if we don't have a summary we emit the content
                    if (siteConfig.AlwaysIncludeContentInRSS || entry.Description == null || entry.Description.Length == 0)
                    {
                        atomEntry.Summary = null;                         // remove empty summary tag

                        try
                        {
                            AtomContent atomContent = new AtomContent();
                            atomContent.Type = "xhtml";

                            XmlDocument xmlDoc2 = new XmlDocument();
                            xmlDoc2.LoadXml(ContentFormatter.FormatContentAsXHTML(PreprocessItemContent(entry.EntryId, entry.Content), "div"));
                            atomContent.anyElements = new XmlElement[] { xmlDoc2.DocumentElement };

                            // set the langauge for the content item
                            atomContent.Lang = entry.Language;

                            atomEntry.Content = atomContent;
                        }
                        catch (Exception)                        //XHTML isn't happening today
                        {
                            //Try again as HTML
                            AtomContent atomContent = new AtomContent();
                            atomContent.Type        = "html";
                            atomContent.TextContent = ContentFormatter.FormatContentAsHTML(PreprocessItemContent(entry.EntryId, entry.Content));
                            // set the langauge for the content item
                            atomContent.Lang = entry.Language;

                            atomEntry.Content = atomContent;
                        }
                    }

                    if (atomEntry.ModifiedUtc > feedModified)
                    {
                        feedModified = atomEntry.ModifiedUtc;
                    }

                    atomFeed.Entries.Add(atomEntry);
                }

                // set feed modified date to the most recent entry date
                atomFeed.ModifiedUtc = feedModified;
                cache.Insert(CacheKey, atomFeed, DateTime.Now.AddMinutes(5));
            }
            return(atomFeed);
        }