0

I have a really beginner's level question.

I am trying to get going with Ninject in an ASP.NET WebForms application, but I don't know how. I know how to do this, roughly, in MVC 3, as described here. But, I'm stuck when trying to do the same thing in a WebForms app.

For example, in a WebForms app, where do I setup binding similar to below?

private static void RegisterServices(IKernel kernel)  
{  
  kernel.Bind<IRepository>().To<MyRepositoryImpl>();
  kernel.Bind<IWebData>().To<MyWebDAtaImpl>();
}

This is an example of the kinds of questions I have, and am hoping the SO community can help with. I have lots of such questions, but in an attempt to just start somewhere, I'll leave off with that one question for now.

Community
  • 1
  • 1
campbelt
  • 1,573
  • 5
  • 27
  • 43

1 Answers1

3

Do you mean WebForms?

You will want to do container registration in the global.asax, in the Application_OnStart event.

Phil Sandler
  • 27,544
  • 21
  • 86
  • 147
  • Yeah, thanks for the clarification.I will try adding the binding in the Application_OnStart event and see how it goes. Thank you! – campbelt Aug 03 '11 at 19:52
  • I found a fantastic answer to this question at http://stackoverflow.com/questions/4933695/how-can-i-implement-ninject-or-di-on-asp-net-web-forms/6121250#6121250 – campbelt Aug 04 '11 at 01:17