繁体   English   中英

在 Web 部署发布到远程 IIS 后,ASP.NET Core 3.1 身份持久化 cookie 身份验证仍然失败

[英]ASP.NET Core 3.1 identity persist cookie authentication after web deploy publish to remote IIS still fails

在 Web 部署发布到远程 IIS 后,ASP.NET Core 3.1 身份持久化 cookie 身份验证仍然失败

我正在使用这个答案的解决方案https://stackoverflow.com/a/56493862/3650307

public Startup(IConfiguration configuration, IHostingEnvironment environment) {
  Configuration = configuration;
  hostingEnvironment = environment;
}

private IHostingEnvironment hostingEnvironment;

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) {
  // create a directory for keys if it doesn't exist
  // it'll be created in the root, beside the wwwroot directory
  var keysDirectoryName = "Keys";
  var keysDirectoryPath = Path.Combine(hostingEnvironment.ContentRootPath, keysDirectoryName);
  if (!Directory.Exists(keysDirectoryPath)) {
    Directory.CreateDirectory(keysDirectoryPath);
  }
  services.AddDataProtection()
    .PersistKeysToFileSystem(new DirectoryInfo(keysDirectoryPath))
    .SetApplicationName("CustomCookieAuthentication");

  services.Configure<CookiePolicyOptions>(options =>
  {
  ...

我已经做了很多谷歌搜索和研究(如果这个也与 asp.net core 3.1 https://stackoverflow.com/a/3516058/3650307 相关

我正在部署到基于俄语的 Web 托管 REG.RU,在 IIS Web 部署发布后,我的 cookie 仍然不存在,每次重新部署后我都必须再次登录。

我不明白该社区会建议我广泛检查我的远程服务器托管日志,但至少可以帮助我寻找什么以及如何在远程 windows web asp.net 应用程序托管提供商上启用和查看日志(一般来说,REG.ru 托管使用 Plesk 管理面板,但我知道可能在 web.config 或其他 ASP.NET 应用程序文件夹文件管理器中启用了日志记录)

是否有其他人最近在将 IIS Web 部署发布到 ASP.NET Windows 主机时遇到了持久性 cookie 登录 asp.net core 3.1 身份的问题?

在发布过程中重写 web.config 文件是否会影响应用程序的重新启动,因此即使考虑了 Keys 存储,cookie 也不再起作用? 如果是,有没有办法防止 web.config 重写?

是的,当我检查 xml 密钥文件时,密钥文件夹出现在 FTP 上

IsPersistent 授予的持久性仅意味着身份验证将通过浏览会话持续进行(即,即使浏览器关闭也会保留)。 您需要结合持久性和设置 cookie 的过期时间。 可以使用 ExpireTimeSpan 选项通过CookieAuthenticationOptions设置 cookie 的过期时间。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM