WCSF 2.0 And IIS7 Integrated Pipeline Mode
While preparing the demos for my session at TechDays Portugal 2008, I've noticed that the Web Client Software Factory 2.0 doesn't work with IIS7 in integrated pipeline mode because it's trying to access the Request property of the current HTTP Context from the HTTP Application Start "event", which is not available at this point.
This is an already known issue and you can vote to get it solved.
Meanwhile, there are two ways to work around this:
Changing the Composite Web Application Block
If you are comfortable with having your own build of this block instead of the provided strong named one, you only need to change one statement in the WebConfigModuleInfoStore class (WCSFBlocks-Feb2008\CompositeWeb\Source\CompositeWeb\Services\WebConfigModuleInfoStore.cs, line 105).
Just replace:
configuration = WebConfigurationManager.OpenWebConfiguration(context.Request.ApplicationPath + "/" + configFilePath.Replace(context.Request.PhysicalApplicationPath, ""));
with:
configuration =
WebConfigurationManager.OpenWebConfiguration(HttpRuntime.AppDomainAppVirtualPath + "/" +
configFilePath.Substring(HttpRuntime.AppDomainAppPath.Length));
Changing the application
If you prefer to (or have to) use the provided and strong named version of the Composite Web Application Block, you can always change your application.
Just open the generated global.asax file:
<%@ Application Language="C#" Inherits="Microsoft.Practices.CompositeWeb.WebClientApplication" %>
and add:
<script RunAt="server">private bool </SPAN>initialized; <SPAN style="COLOR: blue">protected override void </SPAN>Application_Start(<SPAN style="COLOR: blue">object </SPAN>sender, <SPAN style="COLOR: #2b91af">EventArgs </SPAN>e) { <SPAN style="COLOR: blue">this</SPAN>.initialized = <SPAN style="COLOR: blue">false</SPAN>; } <SPAN style="COLOR: blue">protected void </SPAN>Application_BeginRequest(<SPAN style="COLOR: blue">object </SPAN>sender, <SPAN style="COLOR: #2b91af">EventArgs </SPAN>e) { <SPAN style="COLOR: blue">if </SPAN>(!<SPAN style="COLOR: blue">this</SPAN>.initialized) { <SPAN style="COLOR: blue">this</SPAN>.initialized = <SPAN style="COLOR: blue">true</SPAN>; <SPAN style="COLOR: blue">base</SPAN>.Application_Start(sender, e); } }
</script>