失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 计算机专业问题解答 计算机科学专业的编程问题 解答 有问必答

计算机专业问题解答 计算机科学专业的编程问题 解答 有问必答

时间:2019-07-15 02:10:01

相关推荐

计算机专业问题解答 计算机科学专业的编程问题 解答 有问必答

该楼层疑似违规已被系统折叠隐藏此楼查看此楼

问题五

webApi 的cookie验证问题

net core MVC 基于cookie验证用户是否登录,但是在.net core WebAapi 中验证失败,请求是带有登录cookie的 但是User.Identity.IsAuthentication总是false

.net core webapi 是不是有什么不同呢?

配置都是正确的,

services.AddCors(options => { options.AddPolicy("AllowAllOrigin", builder => { builder.WithOrigins("http://xxx", "https://xxx") .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials(); });});services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, o => { ...... }); services.AddApiVersioning(option => { option.DefaultApiVersion = new Microsoft.AspNetCore.Mvc.ApiVersion(1, 0); option.AssumeDefaultVersionWhenUnspecified = true; option.ReportApiVersions = true; });///app.UseAuthentication();app.UseMvc()

如果觉得《计算机专业问题解答 计算机科学专业的编程问题 解答 有问必答》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。