Accessing UmbracoHelper in HttpHandler request

Working with UmbracoHelper and IPublishedContent in HttpHandler

  • Share

If you were planning to create sitemap.xml in Umbraco, you most probably were doing it with HttpHandler. This was fine until Umbraco version 6.2.2.

If your website was running in lower version, most probably after update your HttpHandler were crashing since UmbracoContext.Current returns null.

However, there is a workaround for this. You need to initialize UmbracoContext on ProcessRequest of your HtppHandler as a first thing.

        public void ProcessRequest(HttpContext context)
                new HttpContextWrapper(HttpContext.Current),

            //The rest of your code

This simple fix should allow you accessing UmbracoHelper methods and published Umbraco context from App_Data/umbraco.config

  • Share


Purpose of the code contained in snippets or available for download in this article is solely for learning and demo purposes. Author will not be held responsible for any failure or damages caused due to any other usage.

Comments for this article

comments powered by Disqus