Просмотр исходного кода

!572 update Admin.NET/Admin.NET.Core/Service/Common/CommonService.cs.
Merge pull request !572 from 尽在可能/N/A

zuohuaijun 3 лет назад
Родитель
Сommit
32aed5f136
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      Admin.NET/Admin.NET.Core/Service/Common/CommonService.cs

+ 5 - 2
Admin.NET/Admin.NET.Core/Service/Common/CommonService.cs

@@ -1,4 +1,4 @@
-namespace Admin.NET.Core.Service;
+namespace Admin.NET.Core.Service;
 
 public class CommonService : ICommonService, IScoped
 {
@@ -71,7 +71,10 @@ public class CommonService : ICommonService, IScoped
     /// <returns></returns>
     public string GetHost()
     {
-        return $"{_httpContextAccessor.HttpContext.Request.Scheme}://{_httpContextAccessor.HttpContext.Request.Host.Value}";
+         var localhost=$"{_httpContextAccessor.HttpContext.Request.Scheme}://{_httpContextAccessor.HttpContext.Request.Host.Value}";
+        if(_httpContextAccessor.HttpContext.Request.Headers.Referer.Count>0)
+            localhost = _httpContextAccessor.HttpContext.Request.Headers.Referer[0].TrimEnd('/');
+        return localhost;
     }
 
     /// <summary>