运行时使用的 IHttpAsyncHandler 实例
给定一个 IHttpAsyncHandler 实例 A,A 会是接收 EndProcessRequest 回调的实例吗?如果有的话,有保证吗? IsReusable 属性是否会改变行为?
尝试测试它已经足够复杂了,我想伸出手来看看其他人是否已经走上了这条路。
我目前有一个 IHttpAsyncHandler,它使用发送到 EndProcessRequest 的状态对象,并且一切正常。但是,如果我可以在实例级变量(如属性或字段)中保留状态,那么我可以大大清理代码。
想法?
Given an IHttpAsyncHandler instance A, will A be the instance that receives the EndProcessRequest callback? If so, it is guaranteed? Does the IsReusable property alter the behavior at all?
It's complicated enough to try to test that I wanted to reach out and see if someone else had already been down this road.
I currently have a IHttpAsyncHandler that uses a state object that gets sent to EndProcessRequest and everything is working perfectly. However, I could clean the code considerably if I could preserve state in an instance level variable like a property or field.
Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,将在 EndProcessRequest 方法中调用相同的实例。
如果您将每个请求状态放在处理程序上,isReusable getter 应该返回“false”,否则 ASP.NET 运行时将不会从一个请求到另一个请求重新实例化您的处理程序,而不是为每个请求重新创建一个全新的实例。
Yes, the same instance will be called in the EndProcessRequest method.
If you are putting per request state on the handler though, the isReusable getter should return 'false', otherwise the ASP.NET run time will not re-instantiate your handler from request to request instead of recreating a whole new instance per request.