I am upgrading an old WebForms application. However, it's not picking up the custom themes.
My web.config file contains the following:
<system.web>
<httpModules>
<add name="ThemeManager" type="SoftCircuits.MediCorp.ThemeManager"/>
</httpModules>
</system.web>
And here's part of the definition of the class:
public class ThemeManager : IHttpModule
{
const string _defaultTheme = "BlueSky";
public ThemeManager()
{
}
public void Init(HttpApplication app)
{
app.PreRequestHandlerExecute += new EventHandler(Context_PreRequestHandlerExecute);
}
void Context_PreRequestHandlerExecute(object sender, EventArgs e)
{
if (HttpContext.Current.CurrentHandler is Page && HttpContext.Current.Session != null)
{
Page page = (Page)HttpContext.Current.CurrentHandler;
// Note: To override the theme set here, set Theme = null in page's PreInit event
if (page != null && !HttpContext.Current.Request.FilePath.Contains("Help/"))
{
...
But it appears that the class is never instantiated. I can set breakpoints in the constructor, the Init()
handler, or the PreRequestHandlerExecute()
handler, and none of those breakpoints are hit.
This worked at one time. Can anyone see what is missing?
Note: I don't know if it makes any difference but I also specify <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
in my web.config file.
Turns out the web.config syntax has changed for IIS 7.0 Integrated mode (whatever Integrated mode means).
Instead of the configuration in my question, it needs to be done as follows.
<system.webServer>
<modules>
<add name="ThemeManager" type="SoftCircuits.MediCorp.ThemeManager"/>
</modules>
</system.webServer>
That fixed it for me.
http://msdn.microsoft.com/en-us/library/vstudio/ms227673(v=vs.100).aspx