public string ExtractUrl(Uripart uriPart, IHttpContextRequest httpRequest)
        {
            var request = (httpRequest as HttpContextRequestLegacy).HttpRequest;

            if (request == null)
            {
                return(null);
            }

            var urlBuilder = new StringBuilder();

            if ((uriPart & Uripart.Scheme) == Uripart.Scheme && !String.IsNullOrWhiteSpace(request.Url.Scheme))
            {
                urlBuilder.Append(request.Url.Scheme + "://");
            }
            if ((uriPart & Uripart.Host) == Uripart.Host)
            {
                urlBuilder.Append(request.Url.DnsSafeHost);
            }
            if ((uriPart & Uripart.Port) == Uripart.Port && request.Url.Port > 0)
            {
                urlBuilder.Append(":" + request.Url.Port);
            }
            if ((uriPart & Uripart.Path) == Uripart.Path)
            {
                urlBuilder.Append(request.Url.LocalPath);
            }
            if ((uriPart & Uripart.Query) == Uripart.Query)
            {
                urlBuilder.Append(request.Url.Query.ClearQueryStringPassword());
            }
            return(urlBuilder.ToString());
        }
        public string ExtractUrl(Uripart uriPart, IHttpContextRequest httpRequest)
        {
            var request = (httpRequest as HttpContextRequestCore).HttpRequest;

            if (request == null)
            {
                return(null);
            }

            var urlBuilder = new StringBuilder();

            if ((uriPart & Uripart.Scheme) == Uripart.Scheme && !String.IsNullOrWhiteSpace(request.Scheme))
            {
                urlBuilder.Append(request.Scheme + "://");
            }
            if ((uriPart & Uripart.Host) == Uripart.Host)
            {
                urlBuilder.Append(request.Host.Host);
            }
            if ((uriPart & Uripart.Port) == Uripart.Port && request.Host.Port > 0)
            {
                urlBuilder.Append(":" + request.Host.Port);
            }
            if ((uriPart & Uripart.Path) == Uripart.Path)
            {
                urlBuilder.Append(request.PathBase.ToUriComponent());
                urlBuilder.Append(request.Path.ToUriComponent());
            }
            if ((uriPart & Uripart.Query) == Uripart.Query)
            {
                urlBuilder.Append(request.QueryString.Value.ClearQueryStringPassword());
            }
            return(urlBuilder.ToString());
        }