From 9574073355c74e91233f822b1a21ff0bc34e0b61 Mon Sep 17 00:00:00 2001 From: Argo-MacBookPro Date: Sun, 16 Sep 2018 13:23:26 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81=EF=BC=9A?= =?UTF-8?q?=E7=B2=BE=E7=AE=80Login=E5=86=99=E6=B3=95=EF=BC=8C=E6=AD=A4?= =?UTF-8?q?=E5=A4=84=E6=B3=A8=E6=84=8F=E4=B8=8D=E8=83=BD=E4=BD=BF=E7=94=A8?= =?UTF-8?q?this.SignIn=E6=96=B9=E6=B3=95=EF=BC=8C=E6=AD=A4=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E4=B8=8D=E8=BF=9B=E8=A1=8CCookie=E7=9A=84=E5=86=99?= =?UTF-8?q?=E5=85=A5=E4=BB=85=E4=BB=85=E8=BF=94=E5=9B=9E=E4=B8=80=E4=B8=AA?= =?UTF-8?q?SignInResult?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Controllers/AccountController.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Bootstrap.Admin/Controllers/AccountController.cs b/Bootstrap.Admin/Controllers/AccountController.cs index be80bf7f..f7e72a26 100644 --- a/Bootstrap.Admin/Controllers/AccountController.cs +++ b/Bootstrap.Admin/Controllers/AccountController.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using System.Linq; using System.Security.Claims; using System.Threading.Tasks; @@ -42,8 +43,8 @@ namespace Bootstrap.Admin.Controllers await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity), new AuthenticationProperties() { IsPersistent = remember == "true" }); } // redirect origin url - var originUrl = Request.Query[CookieAuthenticationDefaults.ReturnUrlParameter]; - return Redirect(originUrl.Count == 1 ? originUrl[0] : "~/"); + var originUrl = Request.Query[CookieAuthenticationDefaults.ReturnUrlParameter].FirstOrDefault() ?? "~/Home/Index"; + return Redirect(originUrl); } /// /// Logout this instance.