Sitecore CMS and everything related RSS 2.0
 Monday, November 07, 2005

Handy Sitecore.Contex is thread-local storage, so as soon as leave you leave sweet and warm asp.net request thread, you need to set it up for yourself. Fortunately, it is an easy task: you should pass a Sitecore site name to your child thread  (available as Sitecore.Site.Name in the parent thread if you want to execute in the same site context), and then do a Sitecore.Context.SetActiveSite(aSiteName).

Optionally you might choose to either switch the security checks off
  Sitecore.Context.Security.EnterState(SecurityState.Disabled)
or leave the security intact, pass a user name or id to your thread and do a
  UserItem user = Sitecore.Context.Domain.GetUser(aUserName);
 Sitecore.Context.Security.EnterUser(user);

Sites are setup in <sites> section of the web.config file, so if you want your thread to execute in specific context with its own settings (own database, perhaps) - set up another site in web.config and use its name instead.

Setting up context when you spawn a new thread is rather important - even if you don't use it directly, most of the higher-level API does.
Monday, November 07, 2005 11:23:40 AM (FLE Standard Time, UTC+02:00)  #    Comments [0]
Sitecore | Security
Comments are closed.
Archive
<January 2009>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567
Blogroll
 Alex de Groot
Few words about SiteCore from Holland
 Alexander Shyba
Sitecore Support
 Anders Dreyer
Anders Dreyer on Sitecore Development
 Jakob Christensen
Sitecore Core Development
 Lars Fløe Nielsen
Lars's ramblings about development and business processes
 Ole Thrane
Sitecore API
 Runi Thomsen
Runi Thomsen Sitecore Toughts
 The Sitecore Experience
The Sitecore Experience
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2009
Alexey Rusakov
Sign In
Statistics
Total Posts: 201
This Year: 0
This Month: 0
This Week: 0
Comments: 0
Themes
Pick a theme:
All Content © 2009, Alexey Rusakov
DasBlog theme 'Business' created by Christoph De Baene (delarou)