我有屬於DL的某些用戶的重定向方案。這是一個經過AAD認證的應用程序。 如果用戶屬於某個DL,則應加載該應用程序。其他方面,用戶應該被重定向到另一個應用程序(「https://validreferrer」)。他必須點擊另一個應用程序(「https://validreferrer」)上的鏈接來到我的應用程序。 我正在將此檢查置於post_authenticate事件中。我檢查推薦人。如果這是一個有效的推薦人(「https://validreferrer」),則繼續。如果不檢查用戶是否屬於DL。如果用戶不屬於DL,則將用戶重定向到「https://validreferrer」,否則設置驗證的cookie並繼續訪問該站點。無法在Application_PostAuthenticateRequest中的AAD身份驗證後得到正確的引用者
如果用戶不屬於DL-第一次引用來自https://login.microsoftonline.com/72f98 ...因爲請求是從AD進行身份驗證的,所以引用者變爲this,引用者檢查失敗。然後,執行屬於DL檢查的用戶並且用戶被重定向。 但是,如果用戶第一次點擊另一個應用程序 - 「https://validreferrer」,然後單擊鏈接來到我的應用程序,引用者仍然是https://login.microsoftonline.com/72f98 ...而不是「https://validreferrer」,並且用戶再次驗證屬於DL然後重定向。現在,如果用戶再次點擊外部網站(「https://validreferrer」)來訪問我的網站,則推薦鏈接正確。 我該如何避免這種雙重重定向。 我試圖在會話開始時捕獲引用者,這是用戶第一次通過正確的站點(「https://validreferrer」)來訪問,但引用者(「https://validreferrer」)僅適用於Chrome。不在IE或Edge的情況下。 有沒有我可以用來區分這兩個調用的任何請求屬性?或者還有其他解決這個問題的方法嗎?
示例代碼 -
//這只是通過chrome捕獲引用。在IE和邊緣 不工作保護無效在session_start(對象發件人,EventArgs的)
{
if (Request.UrlReferrer != null &&
HttpContext.Current.Request.Cookies["UrlReferrer"] == null)
{
HttpContext.Current.Response.Cookies.Add(new HttpCookie("UrlReferrer", Request.UrlReferrer.ToString()));
}
}
保護無效Application_PostAuthenticateRequest(對象發件人,EventArgs的) {
if (this.Request.IsAuthenticated && HttpContext.Current.Request.Cookies["Validated"] == null)
{
bool userinDL= true;
//check if the referrer is correctly set do nothing
//else check if this is a ring zero user. If not, redirect
if ((Request.UrlReferrer == null || !Request.UrlReferrer.ToString().Contains("https://validreferrer")))
{
userinDL= CheckuserMembership();
if (!userinDL)
{
Response.Redirect("https://validreferrer");
}
else
{
HttpContext.Current.Response.Cookies.Add(new HttpCookie("Validated", "true"));
}
}
}
else
{
HttpContext.Current.Response.Cookies.Add(new HttpCookie("Validated", "true"));
}
}
}