Ninject.Web, OnePerRequestModule, and IIS7 Integrated Pipeline
Posted
by Ted
on Stack Overflow
See other posts from Stack Overflow
or by Ted
Published on 2010-03-17T21:01:46Z
Indexed on
2010/03/18
0:11 UTC
Read the original article
Hit count: 1500
Using Ninject.Web with ASP.NET WebForms project. Works without issues using classic pipeline, but when it's under integrated pipeline, a null reference exception occurs on every request (which I've narrowed down to the use of the OnePerRequestModule):
[NullReferenceException: Object reference not set to an instance of an object.] System.Web.PipelineStepManager.ResumeSteps(Exception error) +1216 System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) +113 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +616
The above always occurs unless I remove the OnePerRequestModule initializization. occurs consistently on a very basic test app I put together. On a standard app where I actually want to implement it, I can solve the issue by initializing the OnePerRequestModule like so:
protected override IKernel CreateKernel()
{
// This will always blow up.
//var module = new OnePerRequestModule();
//module.Init(this);
IKernel kernel = new StandardKernel(new MyModule());
// This works on larger app, but on basic app, it makes no difference under integrated pipeline as the above exception is always thrown.
var module = new OnePerRequestModule();
module.Init(this);
return kernel;
}
Before I start spelunking further, is anybody out there using Ninject.Web extension successfully under the integrated pipeline in IIS7 AND using the OnePerRequestModule? There are certain restrictions for modules under the integrated pipeline that weren't there in previous IIS versions/classic pipeline.
Quickly thrown together sample project at http://www.filedropper.com/test_59
And in case it's not obvious with Ninject.Web: it's an ASP.NET WebForms project.
© Stack Overflow or respective owner