Brian David Berman
Brian David Berman

Reputation: 7694

Configure IoC Container in hybrid ASP.NET WebForms MVC project

How is a hybrid ASP.NET WebForms / ASP.NET MVC supposed to configure an IoC container, such as StructureMap? For example, if I was to apply StructureMap to an ASP.NET MVC app, I'd simply use the Dependency Resolver in ASP.NET MVC and I'd be all set. And in an ASP.NET WebForms app, I would use the BuildUp(this) feature of StructureMap in some sort of Base Page class that UI.Page would extend or use Global.asax. But what would you do in the case of a hybrid application? How would something like this look? Would I use global.asax for both in some way?

Upvotes: 2

Views: 844

Answers (1)

JotaBe
JotaBe

Reputation: 39055

You're answering your own question:

  • In Web Forms, use the build up functionality (for example you can have a base Page class and a base User control class. Don't forget this one)
  • In MVC, you can use the dependency resolver.

There's no problem using both at the same time on a hybrid web application.

There are other techniques for web pages that involve handlers. An interesting article:

Upvotes: 3

Related Questions