net core 获取当前页面地址

不能直接获取url  使用扩展属性 进行实现

 public static class HttpRequestExtensions
    {
        public static string GetRequestUrl(this HttpRequest source)
        {
            return $"{source.PathBase}{source.Path}{source.QueryString}";
        }
    }

  引用 using Microsoft.AspNetCore.Http

猜你喜欢

转载自www.cnblogs.com/njccqx/p/10431300.html