2013-01-13 32 views
0

我創建了簡單的HttpModule,我所需要的只是獲取有效Sitecore.Context裏面,但在處理期間我看到我的Sitecore.Context是某種默認值。HttpModule中的Sitecore上下文

我可以得到Sitecore用戶登錄到Sitecore等 如何解決它?

+0

HttpModule何時運行?什麼觸發它? – DougCouto

+0

我需要處理驗證事件 –

+0

當您通過Url訪問Sitecore項目時,HttpModule是否運行? – DougCouto

回答

2

我假設你有一個Sitecore的語境,但它爲空或設置爲錯誤的網站或語言。 你可以改變背景是這樣的:

// switch to the preferred site  
Sitecore.Context.SetActiveSite("yourSiteName"); 

// set the preferred database 
Sitecore.Context.Database = Sitecore.Configuration.Factory.GetDatabase("master"); 

// set the preferred language 
Language language = Sitecore.Globalization.Language.Parse("en"); 
Sitecore.Context.SetLanguage = (language, false); 

你可能也想你處理完成後切換回原來的設置。因此,將原始設置「保存」在變量中是明智的,因此您可以在以後更改它們。

1
相關問題