接口如下: public async Task<Response> ConnectionValidation1(Request request, IFormCollection files)
调用如下:byte[] responseBytes = webClient.UploadData(接口地址, "POST", bytes);
一个文件上传接口,用多线程调用,偶尔出现返回登录页面的html。
登录验证cookie如下 services.AddAuthentication(b =>
{
b.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
b.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
b.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
}).AddCookie(b =>
{
//取消认证票据Cookie的SameSite属性
b.Cookie.SameSite = SameSiteMode.None;
//登陆地址
b.LoginPath = "/Account/Login";
//sid
b.Cookie.Name = "My_SessionId";
// b.Cookie.Domain = "shenniu.core.com";
b.Cookie.Path = "/";
b.Cookie.HttpOnly = true;
b.Cookie.Expiration = new TimeSpan(0, 60, 30);
b.ExpireTimeSpan = new TimeSpan(0, 60, 30);
});接口控制器没有添加[Authorize]属性,继承的是Controller。怎么会出现多线程调用接口偶尔返回登录页面?
调用如下:byte[] responseBytes = webClient.UploadData(接口地址, "POST", bytes);
一个文件上传接口,用多线程调用,偶尔出现返回登录页面的html。
登录验证cookie如下 services.AddAuthentication(b =>
{
b.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
b.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
b.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
}).AddCookie(b =>
{
//取消认证票据Cookie的SameSite属性
b.Cookie.SameSite = SameSiteMode.None;
//登陆地址
b.LoginPath = "/Account/Login";
//sid
b.Cookie.Name = "My_SessionId";
// b.Cookie.Domain = "shenniu.core.com";
b.Cookie.Path = "/";
b.Cookie.HttpOnly = true;
b.Cookie.Expiration = new TimeSpan(0, 60, 30);
b.ExpireTimeSpan = new TimeSpan(0, 60, 30);
});接口控制器没有添加[Authorize]属性,继承的是Controller。怎么会出现多线程调用接口偶尔返回登录页面?
解决方案 »
- 找不到登录判断代码,却实现了登录
- asp.net获取网络打印机
- 简化写
- asp.net 传值
- 怎样在一个GridView中实现全选并且获得该数据行?
- 日历控件的问题
- 请问include file的路径及文件名能否动态给予?
- 初级问题(up有分):在dataGrid中的dropdownlist怎么进行数据邦定,以及选中默认值
- 求有关SqlTransaction方面的资料
- 请问在.net环境中编辑aspx页面为何没有语法弹出提示(比如写Response.就会自动弹出相应地函数。)?在线等待……
- 动态生成的repeater中的按钮无法注册ItemCommand事件
- mvc+iis url重写404问题
你说的偶尔,可能是已经登陆,但浏览器没有关闭过,下次运行,当前上下文是 已登陆 状态
或者是登陆时记住我了
如图,我在出现返回登录页记录了URL日志。记录的requestUrl(请求地址)都是接口地址,并没有出现其他URL情况,足矣说明程序是没问题的,就是不知为何接口会返回登录页。:
个人感觉是接口问题,部署在docker上的
调用接口和浏览器没关联吧浏览器,这个我只是猜想
添加[AllowAnonymous]特性还不行,估计是某种情况下,代码直接跳转到了登陆页面
调用接口和浏览器没关联吧浏览器,这个我只是猜想
添加[AllowAnonymous]特性还不行,估计是某种情况下,代码直接跳转到了登陆页面请求禁止重定向后返回空