我正在尝试获得持久连接,以便用户只需使用密码一次。我使用过这个文档:https://learn.microsoft.com/en-us/aspnet/core/security/authentication/cookie ?tabs=aspnetcore2x 但用户仍然在一段时间后断开连接。
await HttpContext.SignInAsync(
CookieAuthenticationDefaults.AuthenticationScheme,
principal,
new AuthenticationProperties
{
IsPersistent = true
});
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能获得真正持久的连接?
我正在 ASP.Net Core 中编写文件上传,我正在尝试更新进度条,但是当从 javascript 调用 Progress 操作时,会话值未正确更新。
使用以下方法将进度保存在用户会话中:
public static void StoreInt(ISession session, string key, int value)
{
session.SetInt32(key, value);
}
Run Code Online (Sandbox Code Playgroud)
上传:
$.ajax(
{
url: "/Upload",
data: formData,
processData: false,
contentType: false,
type: "POST",
success: function (data) {
clearInterval(intervalId);
$("#progress").hide();
$("#upload-status").show();
}
}
);
Run Code Online (Sandbox Code Playgroud)
获取进度值:
intervalId = setInterval(
function () {
$.post(
"/Upload/Progress",
function (progress) {
$(".progress-bar").css("width", progress + "%").attr("aria-valuenow", progress);
$(".progress-bar").html(progress + "%");
}
);
},
1000
);
Run Code Online (Sandbox Code Playgroud)
上传动作:
[HttpPost]
public async Task<IActionResult> Index(IList<IFormFile> files)
{
SetProgress(HttpContext.Session, 0); …Run Code Online (Sandbox Code Playgroud)