Autofac - 注入性质成asp.net的MVC控制器 [英] Autofac - Inject properties into a asp.net mvc controller

查看:208
本文介绍了Autofac - 注入性质成asp.net的MVC控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基本的控制器从中继承我的所有控制器。该基地控制器有一些属性,我想注入使用属性注入。

I have a base controller from which inherit all my controllers. This base controller has some properties I'd like to inject the using property injection.

我的控制器注册看起来像这样

My controller registration looks like this

builder.RegisterControllers(Assembly.GetExecutingAssembly()

我不知道如何访问的基类,注入的属性。

I don't know how to access the base class and inject the properties.

推荐答案

这应该工作:

builder.RegisterControllers(typeof(MvcApplication).Assembly).PropertiesAutowired();

在autofac网站上的一些更多的信息:<一href=\"http://$c$c.google.com/p/autofac/wiki/PropertyInjection\">http://$c$c.google.com/p/autofac/wiki/PropertyInjection

这篇关于Autofac - 注入性质成asp.net的MVC控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆