手机网站在哪里找到,seo是如何优化,wordpress 字体库,怎么做兼职网站1.记录点击页面的地址#xff0c;如果点击页面时未登录#xff0c;直接跳转到登录页面#xff0c;登录后直接跳转到自己点击的页面 2.创建授权过滤器
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System.Web;namespace Log4NetTest
{/…1.记录点击页面的地址如果点击页面时未登录直接跳转到登录页面登录后直接跳转到自己点击的页面 2.创建授权过滤器
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System.Web;namespace Log4NetTest
{//授权过滤器public class CustomerAuthorizeAttribute : Attribute, IAuthorizationFilter{public void OnAuthorization(AuthorizationFilterContext context){//获取目前地址var controller context.RouteData.Values[controller];var action context.RouteData.Values[action];//判断是否登录if (!context.HttpContext.User.Identity!.IsAuthenticated){//记录要跳转的页面路径context.Result newRedirectToActionResult(Login, WeatherForecast,new { RedirectUrl HttpUtility.UrlEncode($/{controller}/{action}) });}}}
}2.登录接口
[HttpPost]public async TaskIActionResult Login(string usename, string pwd, string RedirectUrl){var user await _userManager.FindByNameAsync(usename);if (user ! null){var re await _signInManager.PasswordSignInAsync(user, pwd, false, false);if (re.Succeeded){if (!string.IsNullOrEmpty(RedirectUrl)){//进行页面跳转return Redirect(HttpUtility.HtmlDecode(RedirectUrl));}return Ok();}return Ok();}return Ok();}