Pål Malmberg
Member since: 2008

How do I get or set the CurrentContext from i.e. a console application running beside the web application?

 I need access to the system outside to import persons etc.

Apr 16, 2009 16:13
Member since: 2007

Hi Pål,

Actually the Community system is dependent on a http context to be able to start up. If you want to use the community system in a console app you will have to fake a http context. Johan Olofsson at EPiServer has written three blog posts how to achieve this and attached sample code. You can find the blog posts here:

Best regards,

Apr 29, 2009 17:45
Member since: 2008

I have read the blogs on how to fake the HttpContext, but even though I now have HttpContext my CommunitySystem.CurrentContext is still null.

Any ideas?

May 11, 2009 11:20


Once you have HttpContext you will need to invoke EPiServer.Common.Settings.LoadSettings(). I think that that in turn will require you to have an app.config, simillar to a web.config, in your application, a license file in the bin-folder and probably a few other files from a real installation as well.

It was a while since I last did this so I'm not a 100% sure what LoadSettings() will require, but perhaps you can try it out and let us know if it worked, and if it didn't, what exception is thrown.

Edited, May 11, 2009 18:57
Pål Malmberg
Member since: 2008
I skipped this and made a webservice instead. Works ok, but I dont know about the performance loss.
May 12, 2009 15:40
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.