Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
- <sitecore>
- <customHandlers>
- <handler trigger="sitemap.xml" handler="sitemap.ashx" />
- </customHandlers>
- </sitecore>
- </configuration>
- <add path="sitemap.ashx" verb="*" type="MySite.CustomSitecore.Handlers.SitemapHandler,MySite" name="SitemapXml" />
- namespace MySite.CustomSitecore.Handlers
- {
- public class SitemapHandler : IHttpHandler
- {
- public bool IsReusable
- {
- get
- {
- throw new NotImplementedException();
- }
- }
- public void ProcessRequest(HttpContext context)
- {
- try
- {
- var curSite = Sitecore.Context.Site;
- var m_Sites = SitemapManagerConfiguration.GetSites();
- foreach (DictionaryEntry site in m_Sites)
- {
- if (site.Key.ToString().Equals(curSite.Name))
- {
- var filepath = site.Value;
- HttpContext.Current.Response.Redirect("/" + filepath, false);
- return;
- }
- }
- return;
- }
- catch (Exception ex)
- {
- Log.Info("Error in SitemapHandler: " + ex, this);
- }
- }
- }
- }
- HttpContext.Current.Response.StatusCode = 200;
- HttpContext.Current.Response.ContentType = "text/xml";
- HttpContext.Current.Response.AddHeader("Location", "/" + filepath);
- HttpContext.Current.Response.End();
- return;
Add Comment
Please, Sign In to add comment