I'm following up with issue opened on home repository: https://github.com/aspnet/Home/issues/1543
I guess that was a wrong place to ask the question.
How to call a controller action method in C# and get IActionResult back from the executed controller?
Is your question still about use of methods in Internal
namespaces, specifically whether using ControllerActionExecutor
is the right thing to do for your CMS scenario?
If yes, the answer is "it depends". Classes in Internal
namespaces are subject to change and not intended for primary scenarios. But of course, your scenario may need ControllerActionExecutor
and you might be fine with future breaking changes.
@sebastienros may have some ideas on alternate approaches for your scenario. Or you could start with Orchard 2 instead of "just" MVC.
One thought: Would creating an alternate IViewComponentInvoker
which delegates to DefaultViewComponentInvoker
and does extra stuff in InvokeAsync()
work for you?
Thanks @dougbu for replying.
I have tried ViewComponents, however, it doesn't support other verbs such as POST, PUT and DELETE. I guess ViewComponents are ideal for rendering trivial components such as navigation and language switcher.
Area is appropriate to build modular components such as Login/Registration, because it supports all verbs and return IActionResults. These components could be rendered anywhere in the website.
In future, it would be highly appreciated when the method "ControllerActionExecutor.Execute()" is available for primary scenarios.
My apologies for the confusing mention of view components; they are not controllers. I was looking at the wrong use of ControllerActionExecutor
and should have mentioned IActionInvoker
and ControllerActionInvoker
. But that wouldn't have been useful since even the ControllerActionInvokerProvider
is in an Internal
namespace. Just ignore that last paragraph...
We are closing this issue because no further action is planned for this issue. If you still have any issues or questions, please log a new issue with any additional details that you have.