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

update Admin.NET/Admin.NET.Core/Service/Common/CommonService.cs.
URL无法重写

Signed-off-by: 尽在可能 <421981095@qq.com>

尽在可能 3 лет назад
Родитель
Сommit
44c4f23d97
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>