autofac,ASP.NET集成和处置 [英] autofac, ASP.NET integration, and Dispose

查看:137
本文介绍了autofac,ASP.NET集成和处置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Autofac新手在这里,但我喜欢我所看到的那么远。我试图把我的解决对象的请求寿命优势,我无法确认请求完成后处置实际发生的事情。

Autofac newbie here, but I like what I see so far. I'm trying to take advantage of request-lifetime of my resolved objects and I'm having trouble confirming that a dispose is actually happening after a request is done.

我有一个一次性的对象,我得到一个页面请求的开始和结束时处理。我使用autofac现在来获取对象的实例,我想看看,如果autofac会做处理我。

I have a disposable object that I get at the start of a page request and dispose at the end. I'm using autofac to get an instance of the object now and I wanted to see if autofac would do the disposing for me.

我已经仪表有问题的对象的Dispose()方法,并在我的网页做的生命周期管理,我可以看到它火。我认为没有证据,当我不处理自己,而是让autofac做到这一点。

i've instrumented the Dispose() method on the object in question, and i can see it 'fire' when my page does the lifetime management. I see no evidence when I don't dispose myself but let autofac do it.

我使用这些说明得到thigns配置,包括web.config中和Global.asax的变化。我能够实例化对象就好了,但如果它真的被布置我不能告诉。是否有另一步?

I'm using these instructions to get thigns configured, including the web.config and global.asax changes. I am able to instantiate the object just fine but I can't tell if it's really being disposed. Is there another step?

推荐答案

我想它了!

我是问错了容器对象实例 - 我是问的应用程序容器的对象,而不是请求容器

I was asking the WRONG container for the object instance - I was asking the application-container for the object and not the request-container.

D'哦!

这篇关于autofac,ASP.NET集成和处置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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