Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As far as I understand, the <strong>PerWebRequestLifestyle</strong> requires an <a href="http://msdn.microsoft.com/en-us/library/System.Web.IHttpModule%28v=vs.110%29.aspx" rel="nofollow">IHttpModule</a> so that it can piggy-back off the <a href="http://msdn.microsoft.com/en-us/library/system.web.ihttpmodule.init%28v=vs.110%29.aspx" rel="nofollow">init method</a> and the <a href="http://msdn.microsoft.com/en-us/library/system.web.httpapplication_events%28v=vs.110%29.aspx" rel="nofollow">HttpApplication events</a> such as <code>BeginRequest</code>.</p> <p>The reason why everything seems to be working is because the module has been initialised and so the PerWebRequestLifestyle is functioning normally.</p> <p>But why is that the case if you didn't include the registration module? <strong>I suspect that it is a legacy instruction and that the container will attempt a registration on its own</strong>, but this isn't documented explicitly.</p> <p>If we take a peek inside CastleWindsor we find something called <code>Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModuleRegistration</code>. It has this method:</p> <pre><code>public static void Run() { Type type = Type.GetType("Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility, Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", false); if (type == null) { return; } MethodInfo method = type.GetMethod("RegisterModule", BindingFlags.Static | BindingFlags.Public); if (method == null) { return; } object[] objArray = new object[] { typeof(PerWebRequestLifestyleModule) }; method.Invoke(null, objArray); } </code></pre> <p>What is <code>DynamicModuleUtility</code>? A quick search reveals a page written by <a href="http://odetocode.com/about/scott-allen" rel="nofollow">K. Scott Allen</a> called <a href="http://odetocode.com/blogs/scott/archive/2011/02/28/dynamicmoduleutility.aspx" rel="nofollow">DynamicModuleUtility</a>.</p> <blockquote> <p>The DynamicModuleUtility will let you install an HTTP module into the ASP.NET pipeline without making any changes to web.config file.</p> </blockquote> <p>This is only my speculation as to what's going on. You'd have to ask the creators of Castle Windsor for details on exactly how things are working.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload