Autofac - Make sure that the controller has a parameterless public constructor

后端 未结 6 1220
情歌与酒
情歌与酒 2021-02-07 04:28

I know it\'s been asked and answered before - the reason I\'m asking is because (I think) I tried all suggested solutions to this problem but still can\'t resolve it.

I

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-07 05:10

    I think you are missing registering autofac at app start code.

    Use this:

    protected void Application_Start()
    {
        IocConfig.Config();
        AreaRegistration.RegisterAllAreas();
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
       BundleConfig.RegisterBundles(BundleTable.Bundles);
    }
    

    For more details, refer this blog http://www.codeproject.com/Articles/808894/IoC-in-ASP-NET-MVC-using-Autofac

提交回复
热议问题