I created simple HttpModule
, all what I need is just get is valid Sitecore.Context
inside but during processing I see that my Sitecore.Context
is some kind of default.
I can get Sitecore user that log in to Sitecore, etc. How to fix it ?
I assume you have a Sitecore Context, but it is null or set to the wrong site or language. You can change the context like this:
// 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);
You probably also want to switch back to the original settings after your processing is done. So it is wise to "save" the original settings in a variable so you can change them back afterwards