[英]ASP.NET Redirect user to current custom domain after Azure Active Directory Authentication
我试图将用户重定向到他们尝试访问我的网站的域,然后再重定向到Azure Active Directory登录页面。 我正在使用OpenIDConnect,下面是一些代码,用于定义登录后需要重定向用户的URI:
Notifications = new OpenIdConnectAuthenticationNotifications
{
RedirectToIdentityProvider = context =>
{
string appBaseUrl = "https://" + context.Request.Host + context.Request.PathBase + context.Request.Uri.PathAndQuery;
context.ProtocolMessage.RedirectUri = "https://" + context.Request.Host + context.Request.PathBase + context.Request.Uri.PathAndQuery;
context.ProtocolMessage.PostLogoutRedirectUri = appBaseUrl;
return Task.FromResult(0);
},
//custom validation
SecurityTokenValidated = onValidate,
AuthenticationFailed = onFailure
}
我遇到的问题是我有自定义域和context.Request.Host
返回我网站的通用域,而不是我所需要的。
例如,我有我的网站和2个自定义域:
mywebsite.azurewebsites.net
通用主机 mywebsite.customdomain1.com
mywebsite.customdomain2.com
从mywebsite.customdomain1.com
连接时, context.Request.Host
等于mywebsite.azurewebsites.net
。 不知道我的用户来自哪个域,我被迫将他们重定向到一个唯一的域……这不是很理想。
我在这里有什么选择?
关于我的问题,该问题来自以下事实:我使用CDN从customdomain1
和customdomain2
提供对我的网站的访问。 CDN配置错误,没有让接收到的请求中的原始主机名通过。 我更改了配置,现在一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.