为什么通过 IHttpHandler 调用 IHttpAsyncHandler?

发布于 2024-08-28 08:25:08 字数 415 浏览 11 评论 0原文

我创建了一个派生自 MvcHandler 的自定义处理程序。我的路由使用自定义 RouteHandler,它返回 GetHttpHandler() 的新处理程序,并且我在自定义处理程序中重写 ProcessRequest()。对 GetHttpHandler 的调用正在触发断点,并且肯定会调用我的处理程序的构造函数,但在基础 MvcHandler 上调用 BeginProcessRequest(),而不是 ProcessRequest()。

当我没有执行任何操作来调用异步方法时,为什么会调用它们?我不想要异步处理,而且我当然没有做任何明确的事情来获得它。我的控制器都派生自 Controller,而不是 AsyncController。

我现在没有源代码,但如果需要的话我可以稍后添加。我希望有人可能知道在不需要时可能会调用 BeginProcessRequest 的一些原因。

I made a custom handler that derives from MvcHandler. I have my routes using a custom RouteHandler that returns my new handler for GetHttpHandler(), and I override ProcessRequest() in my custom handler. The call to GetHttpHandler is triggering a breakpoint and my handler's constructor is definitely being called, but BeginProcessRequest() is being called on the base MvcHandler instead of ProcessRequest().

Why are the async methods being called when I haven't done anything to call them? I don't want asynchronous handling, and I certainly didn't do anything explicit to get it. My controllers all derive from Controller, not AsyncController.

I don't have the source code with me right now, but I can add it later if needed. I was hoping someone might know some of the reasons why BeginProcessRequest might be called when it's not wanted.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

渡你暖光 2024-09-04 08:25:08

Brad Wilson 在 Asp.net 论坛上回复了我的帖子,答案如下 http://forums。 asp.net/t/1547898.aspx

简短回答:是的。

添加AsyncController后,
MvcHandler 类需要是
现在是 IHttpAsyncHandler,这意味着
就 ASP.NET 核心而言
就运行时而言,入口点
现在是 BeginProcessRequest 和
EndProcessRequest,而不是 ProcessRequest。

听起来 ProcessRequest 甚至不再被调用,但我可能弄错了。我可以说我在测试中没有看到它。

Brad Wilson responded to my post on the Asp.net forums with the following answer http://forums.asp.net/t/1547898.aspx:

Short answer: yes.

With the addition of AsyncController,
the MvcHandler class needs to be an
IHttpAsyncHandler now, which means
that as far as the ASP.NET core
runtime is concerned, the entry points
are now BeginProcessRequest and
EndProcessRequest, not ProcessRequest.

It sounds like ProcessRequest is not even called anymore, but I could be mistaken. I can say that I haven't seen it in my testing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文