ASP.NET MVC AsyncController xxx已完成
实现 ASP.NET MVC AsyncController 时,xxxCompleted 方法必须是 Public。我想知道这是否意味着可以直接调用 xxxCompleted 方法,或者是否使用 NonAction 或类似的方法在内部对其进行保护?
谢谢。
When implementing ASP.NET MVC AsyncController the xxxCompleted method has to be Public. I'm wondering if this means the xxxCompleted method can be invoked directly, or if this is protected internally using NonAction or something similar?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在内部(并且简单地),构造了异步控制器上的操作的
MethodInfo
数组。构造时,Async
和Completed
后缀将从操作方法名称中删除。如果您尝试调用诸如
IndexCompleted
之类的操作方法,则会搜索此数组,但由于数组中没有IndexCompleted
(因为后缀已被删除),因此 < code>AsyncControllerActionInvoker 报告未找到任何操作。值得自己研究一下源代码:
Internally (and simplistically), there's an array of
MethodInfo
of the actions on the async controller constructed. When it's constructed theAsync
andCompleted
suffixes are stripped off the action method names.If you try an call an action method such as
IndexCompleted
this array is searched but because there isn't anIndexCompleted
in the array (because the suffixes have been removed) theAsyncControllerActionInvoker
reports that no action was found.It's worth having a poke around the source code to see for yourself: