Skip to content

Commit cee5c2a

Browse files
committed
NullReferenceException fixes.
1 parent 165cb2f commit cee5c2a

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
@@ -168,7 +168,6 @@ public virtual async Task<ModuleRequestResult> ExecuteRequestAsync(ModuleRequest
168168
{
169169
// Check if the controller supports IDnnController
170170
var moduleController = controller as IDnnController;
171-
moduleController.IsAsync = true;
172171

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

179+
moduleController.IsAsync = true;
180+
180181
moduleController.ValidateRequest = false;
181182

182183
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)