zoukankan      html  css  js  c++  java
  • asp.net mvc中包含webapi时,token失效产生302的解决方案

    public void ConfigureAuth(IAppBuilder app)
    {
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),
            Provider = new CookieAuthenticationProvider()
            {
                OnApplyRedirect = ctx =>
                {
                    if (!IsApiRequest(ctx.Request))
                    {
                        ctx.Response.Redirect(ctx.RedirectUri);
                    }
                }
            }
        });
    
        app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
    }
    
    private static bool IsApiRequest(IOwinRequest request)
    {
        string apiPath = VirtualPathUtility.ToAbsolute("~/api/");
        return request.Uri.LocalPath.StartsWith(apiPath);
    }
    
  • 相关阅读:
    webform传值
    webform控件以及使用
    SQL Server 基本数据类型
    数据库设计三大范式
    第一阶段考试
    弹出层
    三级联动日期选择
    DOM例题
    JS方法
    DOM
  • 原文地址:https://www.cnblogs.com/tiger2soft/p/5884524.html
Copyright © 2011-2022 走看看