1
public partial class DataPage : System.Web.UI.Page
{
    IPersonPresenter presenter = null;

    public DataPage(IPersonPresenter presenter)
    {
        if (presenter == null) throw new Exception("Didn't receiver the presenter");

        this.presenter = presenter;
    }
}

I need to pass presenter as a Dependency Injection paramter for this ASP.Net web forms class. I tried Global.asax but couldn't find a factory or anything similar. Please help. Thanks.

Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
Ziaullah Khan
  • 2,020
  • 17
  • 20
  • 1
    Last time I looked, ASP.NET Web Forms doesn't have an extensibility point that enable you to do this, but ASP.NET MVC does. For Web Forms, a possible approach is outlined in my book Dependency Injection in .NET, section 7.5 http://affiliate.manning.com/idevaffiliate.php?id=1150_236 – Mark Seemann Mar 02 '14 at 11:18
  • possible duplicate of [Why does everyone say dependency injection in ASP.NET webforms is hard when PageHandlerFactory and IHttpHandlerFactory exist?](http://stackoverflow.com/questions/6504150/why-does-everyone-say-dependency-injection-in-asp-net-webforms-is-hard-when-page) – Steven Mar 02 '14 at 12:29
  • I was mainly trying to have an example of MVP pattern. Could we do it in `Global.asax` file? – Ziaullah Khan Mar 02 '14 at 13:31

0 Answers0