London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

CurrentContext

Vote:
 

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.

#29228
Apr 16, 2009 16:13
Vote:
 

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:

http://labs.episerver.com/en/Blogs/Johano/Dates/2008/6/Hack-Getting-the-html-from-a-PageData-in-EPiServer-CMS5/


http://labs.episerver.com/en/Blogs/Johano/Dates/2008/6/Hack-Getting-the-html-from-a-PageData-in-EPiServer-CMS5-Part2/


http://labs.episerver.com/en/Blogs/Johano/Dates/2008/6/Hack-Faking-HttpContext-under-EPiServer-CMS5/

Best regards,
Tom

#29511
Apr 29, 2009 17:45
Vote:
 

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?

#29726
May 11, 2009 11:20
Vote:
 

Claus,

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.

#29736
Edited, May 11, 2009 18:57
Vote:
 
I skipped this and made a webservice instead. Works ok, but I dont know about the performance loss.
#29763
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.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.