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.
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:
I have read the blogs on how to fake the HttpContext, but even though I now have HttpContext my CommunitySystem.CurrentContext is still null.
Content is edited
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.
© Episerver 2016 |
About Episerver World