首页 新闻 搜索 专区 学院

aspnetcore 3.1 mvc 身份验证 支付宝浏览器失效 无法登录

0
[已解决问题] 解决于 2020-10-10 11:08

关于支付宝浏览器身份验证失效,无法登录。
我设置了CheckConsentNeeded:false
并且身份验证 IsEssential :true
但都在支付宝浏览器无法登录,错误日志是 :AuthenticationScheme: Cookies was not authenticated.

@dudu

public void ConfigureServices (IServiceCollection services) {

        services.Configure<CookiePolicyOptions>(options =>
        {
            // This lambda determines whether user consent for non-essential cookies is needed for a given request.
            options.CheckConsentNeeded = context => false;
            options.MinimumSameSitePolicy = SameSiteMode.None;
        });
        services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(option => {
            option.LoginPath = new PathString("/Visitor/login");
            option.AccessDeniedPath = new PathString("/Visitor/Logout");
            option.Cookie.Path = "/";
            option.Cookie.HttpOnly = true;
            option.Cookie.IsEssential = true;
        });

    }

public void Configure (IApplicationBuilder app, IWebHostEnvironment env) {
        if (env.IsDevelopment()) {
            app.UseDeveloperExceptionPage();
        } else {
            app.UseExceptionHandler("/Home/Error");
            // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            app.UseHsts();
        }

        LogManager.LoadConfiguration("nlog.config");

        app.UseHttpsRedirection();
        app.UseStaticFiles();

        app.UseCookiePolicy();

        app.UseRouting();

        app.UseAuthorization();

        app.UseEndpoints(endpoints => {
            endpoints.MapControllerRoute(
                name: "default",
                pattern: "{controller=visitor}/{action=index}/{id?}");
        });

        app.UseWxPayment();
    }

怎么打开支付宝浏览器?

dudu 1年前

@dudu: 我是一个H5的登记系统,会把网址生成二维码 别人通过微信或支付宝扫码进来注册,那支付宝扫码进到网址 就是支付宝浏览器

Diose 1年前

@dudu: 刚试了下博客园能在支付宝浏览器登录,想问下怎么设置的?

Diose 1年前
< >
分享
最佳答案
0

我们设置了

options.Cookie.SameSite = SameSiteMode.Unspecified;
options.Cookie.SecurePolicy = CookieSecurePolicy.None;

没有设置

options.CheckConsentNeeded = context => false;
option.Cookie.IsEssential = true;
奖励园豆:5
dudu | 高人七级 |园豆:37194 | 2020-10-10 10:46

options.Cookie.SameSite = SameSiteMode.Unspecified;
options.Cookie.SecurePolicy = CookieSecurePolicy.None;

按照博客园这样设置 解决了

谢谢dudu

Diose | 园豆:7 (初学一级) | 2020-10-10 11:08
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册