且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我如何在ASP.NET Web API请求完成后释放资源?

更新时间:2022-02-23 01:05:49

您可以使用名为的 RegisterForDispose 上的的Htt prequestMessage 注册任何资源,你想处理掉了当一个请求就完成了。

You can use the extension called RegisterForDispose on the HttpRequestMessage to register any resources that you would like to dispose off when a request is done.

顺便说一句,你可能想在下面的链接继续寻求关于网络API的下一版本的IQueryable 支持。
HTTP://aspnetwebstack.$c$cplex.com/discussions/359229

BTW, you might want to look at the following link to regarding IQueryable support in next release of Web API. http://aspnetwebstack.codeplex.com/discussions/359229

做事的Dispose()控制器的方法也将是一个解决方案。在网页API ApiController 基于控制器始终是每个实例(每一个请求一个控制器实例)

Doing things in Dispose() method of the Controller would also be a solution. In Web API ApiController based controllers are always per-instance (one controller instance per one request)