我正在尝试在使用 Azure AD 时拒绝授权时更改默认访问被拒绝路径。
例如,在使用 Microsoft 的“将 Azure AD 集成到 ASP.NET Core Web 应用程序”示例时,请参见此处:https : //azure.microsoft.com/en-us/resources/samples/active-directory-dotnet-webapp -openidconnect-aspnetcore/
文章引用了 GitHub 上的示例项目,请参见此处:https : //github.com/Azure-Samples/active-directory-dotnet-webapp-openidconnect-aspnetcore。
我在配置内部选项Startup.cs以更改拒绝访问的默认控制器/方法(即“Account/AccessDenied”)时遇到困难。
有人可以帮助提供对上面的 github 示例项目所需的更改,以便未经授权的用户在被拒绝授权而不是默认的“Account/AccessDenied”时被带到不同的路径?
更新:我在我的项目中添加了@Brad 之前(和现在再次)在启动中建议的内容,但它没有改变,而且我仍然被定向到“Account/AccessDenied”......你能想到任何其他设置可能会管理这个?
对于我的项目(在 Visual Studio 2017 中使用工作或学校帐户身份验证自动创建的 ASP.NET Core Web 应用程序 - Web 应用程序(模型-视图-控制器)),与示例项目不同。我正在引用 NuGet 包Microsoft.AspNetCore.Authentication.AzureAD.UI并按以下方式设置我的 AzureAD(请注意使用.AddAzureAD和 不.AddAzureAd):
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies
// is needed for a given request.
options.CheckConsentNeeded = …Run Code Online (Sandbox Code Playgroud)