Beispiel #1
0
        /// <summary>获取返回地址</summary>
        /// <param name="request">请求对象</param>
        /// <param name="referr">是否使用引用</param>
        /// <returns></returns>
        public virtual String GetReturnUrl(IHttpRequest request, Boolean referr)
        {
            var url = request.Get("r");

            if (url.IsNullOrEmpty())
            {
                url = request.Get("redirect_uri");
            }
            if (url.IsNullOrEmpty() && referr)
            {
#if __CORE__
                url = request.Headers["Referer"].FirstOrDefault() + "";
#else
                url = request.UrlReferrer + "";
#endif
            }
            if (!url.IsNullOrEmpty() && url.StartsWithIgnoreCase("http"))
            {
                var baseUri = request.GetRawUrl();

                var uri = new Uri(url);
                if (uri != null && uri.Host.EqualIgnoreCase(baseUri.Host))
                {
                    url = uri.PathAndQuery;
                }
            }

            return(url);
        }
Beispiel #2
0
        /// <summary>获取回调地址</summary>
        /// <param name="request"></param>
        /// <param name="returnUrl"></param>
        /// <returns></returns>
        public virtual String GetRedirect(IHttpRequest request, String returnUrl = null)
        {
            if (returnUrl.IsNullOrEmpty())
            {
                returnUrl = request.Get("r");
            }
            // 过滤环回重定向
            if (!returnUrl.IsNullOrEmpty() && returnUrl.StartsWithIgnoreCase("/Sso/Login"))
            {
                returnUrl = null;
            }

            var uri = RedirectUrl.AsUri(request.GetRawUrl()) + "";

            return(uri.AppendReturn(returnUrl));
        }