diff --git a/COMCMS.API/COMCMS.API.csproj b/COMCMS.API/COMCMS.API.csproj index b69fa4d..30903b4 100644 --- a/COMCMS.API/COMCMS.API.csproj +++ b/COMCMS.API/COMCMS.API.csproj @@ -1,7 +1,7 @@ - netcoreapp2.0 + netcoreapp2.1 diff --git a/COMCMS.Common/COMCMS.Common.csproj b/COMCMS.Common/COMCMS.Common.csproj index 66ea28d..17e1db8 100644 --- a/COMCMS.Common/COMCMS.Common.csproj +++ b/COMCMS.Common/COMCMS.Common.csproj @@ -1,13 +1,13 @@ - netcoreapp2.0 + netcoreapp2.1 - + - + diff --git a/COMCMS.Common/CookiesHelper.cs b/COMCMS.Common/CookiesHelper.cs index 9b16881..07dbe96 100644 --- a/COMCMS.Common/CookiesHelper.cs +++ b/COMCMS.Common/CookiesHelper.cs @@ -11,6 +11,10 @@ namespace COMCMS.Common /// public class CookiesHelper { + public CookiesHelper() + { + } + #region 获取Cookies /// /// 读cookie值 diff --git a/COMCMS.Common/MyHttpContext.cs b/COMCMS.Common/MyHttpContext.cs index f051981..02b7032 100644 --- a/COMCMS.Common/MyHttpContext.cs +++ b/COMCMS.Common/MyHttpContext.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; using System.Text; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; namespace COMCMS.Common { @@ -10,19 +12,51 @@ namespace COMCMS.Common /// public static class MyHttpContext { - public static IServiceProvider ServiceProvider; - static MyHttpContext() - { } - - public static HttpContext Current + private static IHttpContextAccessor _accessor; + public static HttpContext Current => _accessor.HttpContext; + internal static void Configure(IHttpContextAccessor accessor) { - get - { - object factory = ServiceProvider.GetService(typeof(IHttpContextAccessor)); - HttpContext context = ((IHttpContextAccessor)factory).HttpContext; - return context; - } + + _accessor = accessor; + } + + //public static IServiceProvider ServiceProvider; + + //static MyHttpContext() + //{ } + + //public static HttpContext Current + //{ + // get + // { + + // object factory = ServiceProvider.GetService();// ServiceProvider.GetService(typeof(IHttpContextAccessor)); + // HttpContext context = ((IHttpContextAccessor)factory).HttpContext; + // return context; + // } + //} //需要在sartup中加入 } + + public static class StaticHttpContextExtensions + { + + public static void AddMyHttpContextAccessor(this IServiceCollection services) + { + + services.AddSingleton(); + } + + public static IApplicationBuilder UseStaticHttpContext(this IApplicationBuilder app) + { + + var httpContextAccessor = app.ApplicationServices.GetRequiredService(); + + MyHttpContext.Configure(httpContextAccessor); + + return app; + + } + } } diff --git a/COMCMS.Core/COMCMS.Core.csproj b/COMCMS.Core/COMCMS.Core.csproj index 64a8f85..4c50a07 100644 --- a/COMCMS.Core/COMCMS.Core.csproj +++ b/COMCMS.Core/COMCMS.Core.csproj @@ -1,7 +1,7 @@ - netcoreapp2.0 + netcoreapp2.1 diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/LoginController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/LoginController.cs index 4246c55..91a09e2 100644 --- a/COMCMS.Web/Areas/AdminCP/Controllers/LoginController.cs +++ b/COMCMS.Web/Areas/AdminCP/Controllers/LoginController.cs @@ -29,6 +29,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers #endregion #region 低版本IE界面 + //判断低版本IE public IActionResult Ie() { return View(); @@ -73,7 +74,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers //验证用户 if (string.IsNullOrEmpty(username)) { - tip.Message = "请输入用户名!"; + tip.Message = "请输入用户名!"+ key; return Json(tip); } if (string.IsNullOrEmpty(password) || Utils.GetStringLength(password) < 5) diff --git a/COMCMS.Web/Areas/AdminCP/Views/Shared/TipPage.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Shared/TipPage.cshtml index fbb98bc..b06e0a0 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Shared/TipPage.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Shared/TipPage.cshtml @@ -40,11 +40,26 @@ - - @Html.Partial("_FooterJS") - + + + + + + + + + + + + + - + + + + + +