Skip to content

Commit 1a091c3

Browse files
committed
NullReferenceException fixes.
1 parent b5e7244 commit 1a091c3

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

DNN Platform/DotNetNuke.Web.Mvc/Framework/Modules/ModuleApplication.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ public virtual async Task<ModuleRequestResult> ExecuteRequestAsync(ModuleRequest
167167
{
168168
// Check if the controller supports IDnnController
169169
var moduleController = controller as IDnnController;
170-
moduleController.IsAsync = true;
171170

172171
// If we couldn't adapt it, we fail. We can't support IController implementations directly :(
173172
// Because we need to retrieve the ActionResult without executing it, IController won't cut it
@@ -176,6 +175,8 @@ public virtual async Task<ModuleRequestResult> ExecuteRequestAsync(ModuleRequest
176175
throw new InvalidOperationException("Could Not Construct Controller");
177176
}
178177

178+
moduleController.IsAsync = true;
179+
179180
moduleController.ValidateRequest = false;
180181

181182
moduleController.DnnPage = context.DnnPage;

DNN Platform/Library/UI/Modules/ModuleInstanceContext.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,16 @@ private void LoadActions(HttpRequest request)
510510
var actionable = this.moduleControl as IActionable;
511511
if (actionable != null)
512512
{
513+
// Async module controls populate ModuleActions only after their async task executes.
514+
// Leave this.actions as null so the Actions getter retries once results are available.
515+
if (this.moduleControl is IAsyncModuleControl && actionable.ModuleActions == null)
516+
{
517+
this.actions = null;
518+
519+
// TODO: Should we throw instead to be able to identify code that tries to call it too early?
520+
return;
521+
}
522+
513523
this.moduleSpecificActions = new ModuleAction(this.GetNextActionID(), Localization.GetString("ModuleSpecificActions.Action", Localization.GlobalResourceFile), string.Empty, string.Empty, string.Empty);
514524

515525
ModuleActionCollection moduleActions = actionable.ModuleActions;

0 commit comments

Comments
 (0)