Async support for MVC controllers.#7193
Conversation
|
Thanks @dimarobert for your efforts and digging into all of the ins-and-outs of the processing going on here! |
|
@dimarobert thank you so much for this, a few things to review, but great amounts of research. @donker and @sachatrauwaen I'm curious to see what impacts if any this has on the MVC Pipeline work that is going on as well |
I will try to give some context for this. In the WebForms implementation here it was easy enough to hook the async stuff over / in between the existing sync stuff due to the fact that Microsoft provided clear boundaries between the sync and async sections of the page execution through the With the MVC implementation I see in #6749 there might be two show stoppers or hard to tackle problems:
|
Great ! But Html helpers on witch a lot is based in the mvc pipeline are synchronous by design in MVC 5. |
So, if Modules in the MvcPipeline do not have access to the controller and the only API surface that the module developer has access to is the |
The modules can have access to the controller, but it run all in a unic controller. That's a raison why we want DNN.Core :) |
|
As I said in my initial comment on this "... if even possible to implement such a There is however the So, looks quite unlikely for the MvcPipeline Razor+ Modules (I hope that is the correct terminology) to be able to support async. |
HtmlHelper.Action is for executing Child Action Controllers, and from what i read, they can not run async. And because there called from a html helper from a razor view, it confirm that they cannot run async. And because Child Controllers are not supported in dotnet core, i prefer to stay on partials and/or ViewComponent patern. |
5f3c696 to
dea3a25
Compare
dea3a25 to
a572bfd
Compare
+ Avoids breaking changes for existing (non-async) MVC modules. + Fix selection of ControllerName from the segments of the ControlSrc when it has a length greater than 2.
…g out the SearchedLocations.
+ some code comments.
436250c to
191af5f
Compare
Closes #4647
Summary
Creates a secondary variant of the MvcHostControl that is executed asynchronously during the page execution.
To avoid any breaking changes to the execution of the existing MVC controls, the control has to opt-in / be marked as requiring asynchronous execution. To do that the control needs to be declared with a ControlSrc in the form of
{ControllerNamespace}/{ControllerName}/async/{ActionName}.mvcinstead of the{ControllerNamespace}/{ControllerName}/{ActionName}.mvcthat existing MVC module controls are defined as.Apart from the action itself, the retrieval of the ModuleActions (
Get{0}Actionsmethod) supportsTask<ModuleActionCollection>for asynchronous execution as well.A few of the methods had to be made
protectedand as such code had to be re-ordered to comply with StyleCop rules. As a result, it may initially appear that more code than expected was modified.Other small fixes:
moduleControl.LocalResourceFile.There is one TODO left in ModuleInstanceContext.cs, and as it states I am not sure if that should return or throw, Throwing, with a good message explaining the issue, would probably help more than the NullReferenceException that would end up being thrown by existing code that would most likely directly iterate over the list received from the method call.
This is also a place where a breaking change could be expected in 3rd party skins or other extensions that try to synchronously read the
ModuleInstanceContext.Actions(list of admin ModuleActions) for asynchronous controls.