asp.net-mvc - 没有重定向 AAD RedirectUri 的 OWIN MVC5
问题描述
使用带有 AAD 模板的 OOTB MVC5,无需任何修改。
我想要做的是在 AAD 的身份验证后将其他自定义声明添加回我的应用程序。配置身份验证:
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationType = CookieAuthenticationDefaults.AuthenticationType,
});
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
RedirectUri = "https://localhost:44336/Account/Signin",
PostLogoutRedirectUri = postLogoutRedirectUri
});
}
在 Azure 门户中,应用程序的回复 URL 也按上述方式输入。应用程序的实际行为是,在 AAD 登录后,重定向只是回到应用程序的根 /,并且没有命中 Account 控制器上的 Signin 操作。
任何想法为什么?我错过了什么?
解决方案
- 您是否还有设置了回复 url/redirecturi 的 web.config 或 appsettings.json?如果是这样,请确保它也在那里匹配。
- 您是仅在本地工作还是这是一个已发布的应用程序?确保您在应用注册和配置中也包含已发布的应用 URL。还要确保这些都是 https 而不是 http(看起来很明显但很容易错过)。
- 确保正确列出您的主页 URL。
- 如果没有看到您的帐户控制器,很难诊断这一点。你能在这里提供这个吗?
如果您还没有,请查看此存储库。它详细描述了如何完成您想要实现的目标。
另请查看此Youtube 教程。
推荐阅读
- git - 如何使用我保存的本地提交和存储更改来恢复 .git 文件夹
- asp.net-core - ASP.NET Core:从 SSAS OLAP Cube 的 SQL Server 获取数据?
- javascript - 仅适用于 alpha 和单个空格的函数
- python - 我不知道我的 ThreadPoolExecutor 会发生什么
- java - Grade-wrapper.properties 和实际版本之间的 Gradle 版本不一致
- c++ - 访问结构指针的 next* 字段中的 int
- c# - 如何找到并写下两个数字之间的质数?
- javascript - 三星 android 设备中的 WebView 问题
- python - 如何为 discord.py 机器人打开/关闭开关
- python - Google Cloud Speech-to-Text API 的问题