public static string GenerateLogOutUrlWithReturnUrl() { var logOutUrl = SitkaRoute <AccountController> .BuildAbsoluteUrlHttpsFromExpression(c => c.LogOff(), NeptuneWebConfiguration.CanonicalHostNameRoot); var returnUrl = HttpContext.Current.Request.Url.AbsoluteUri; return(OnErrorOrNotFoundPage(returnUrl) ? logOutUrl : String.Format("{0}?returnUrl={1}", logOutUrl, HttpUtility.UrlEncode(returnUrl))); }
private static bool OnErrorOrNotFoundPage(string url) { var returnUrlPathAndQuery = new Uri(url).PathAndQuery; var notFoundUrlPathAndQuery = new Uri(SitkaRoute <HomeController> .BuildAbsoluteUrlHttpsFromExpression(x => x.NotFound())).PathAndQuery; var errorUrlPathAndQuery = new Uri(SitkaRoute <HomeController> .BuildAbsoluteUrlHttpsFromExpression(x => x.Error())).PathAndQuery; var onErrorOrNotFoundPage = returnUrlPathAndQuery.StartsWith(notFoundUrlPathAndQuery, StringComparison.InvariantCultureIgnoreCase) || returnUrlPathAndQuery.StartsWith(errorUrlPathAndQuery, StringComparison.InvariantCultureIgnoreCase); return(onErrorOrNotFoundPage); }