Autofac和Web API范围 [英] Autofac and Web API scopes

查看:119
本文介绍了Autofac和Web API范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早些时候,我看到这个:

Earlier i saw this:

.InstancePerApiRequest();

现在我只拿到了这一点:

Now i only got this:

.InstancePerHttpRequest();

难道autofac去掉API-范围是什么?
我有参考Autofac.Integration.WebApi但这个扩展不可用。
是什么InstancePerHtt prequest和InstancePerApiRequest?

Did autofac removed the API-scope? I have the reference Autofac.Integration.WebApi but this extension is not available. What is the difference between InstancePerHttpRequest and InstancePerApiRequest?

推荐答案

InstancePerApiRequest是Web API集成的一部分,InstancePerHtt prequest是MVC集成的一部分。这些实际上都相同标签适用于寿命范围。这是完成,因为你可能有一个既网页API和MVC控制器的依赖服务。

InstancePerApiRequest is part of the Web API integration, and InstancePerHttpRequest is part of the MVC integration. These both actually apply the same tag to the lifetime scope. That was done because you might have services that are dependencies of both Web API and MVC controllers.

这篇关于Autofac和Web API范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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