HttpRequestExtensions.cs 642 Bytes
using System.Text;

namespace Microsoft.AspNetCore.Http
{
    /// <summary>
    /// 获取url地址
    /// https://www.cnblogs.com/atree/p/netcore-absolute-uri.html
    /// </summary>
    public static class HttpRequestExtensions
    {
        public static string GetAbsoluteUri(this HttpRequest request)
        {
            return new StringBuilder()
                .Append(request.Scheme)
                .Append("://")
                .Append(request.Host)
                .Append(request.PathBase)
                .Append(request.Path)
                .Append(request.QueryString)
                .ToString();
        }



    }
}