diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/ApplicationController.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/ApplicationController.cs index 58ed391a27e..6ab70864015 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/ApplicationController.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/ApplicationController.cs @@ -96,7 +96,7 @@ public async Task Create(string returnUrl = null) var model = new CreateOpenIdApplicationViewModel(); - var roleService = HttpContext.RequestServices.GetService(); + var roleService = HttpContext.RequestServices?.GetService(); if (roleService != null) { foreach (var role in await roleService.GetRoleNamesAsync()) @@ -250,7 +250,7 @@ public async Task Edit(string id, string returnUrl = null) Type = await _applicationManager.GetClientTypeAsync(application) }; - var roleService = HttpContext.RequestServices.GetService(); + var roleService = HttpContext.RequestServices?.GetService(); if (roleService != null) { foreach (var role in await roleService.GetRoleNamesAsync())