【发布时间】:2018-07-27 08:12:50
【问题描述】:
我使用 ASP .NET CORE 2。 我在 Startup.cs 中使用此代码
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.LoginPath = new PathString("/Account/Login");
options.AccessDeniedPath = new PathString(/Account/AccessDenied);
options.ExpireTimeSpan = TimeSpan.FromMinutes(3 * 60 + 1);
});
我没有登录,所以我的网站重定向到
https://localhost/Account/Login?ReturnUrl=%252Fbbb。
它在开发中有效。我得到了网址
https://aaaaa.com/?ReturnUrl=%252Fbbb 在生产中。
如何解决?我在 Google 上进行了搜索,但找不到任何东西。
【问题讨论】:
-
Production环境是什么?您是否在 IIS 中托管?您是如何发布到Production环境的? -
你关注Host ASP.NET Core on Linux with Nginx配置你的
UBuntu了吗?对于转发请求,您是否按照本文所述在error handing之后添加app.UseForwardedHeaders? -
可能会钩入OnRedirectToLogin 事件以确认重定向网址。
-
我建议你尝试创建一个中间件来记录请求URL,并检查
https://aaaaa.com/?ReturnUrl=%252Fbbb之前的哪个URL。我认为登录过程中有问题。也许 web.config 中的stdoutLogEnabled就足够了。 -
@yW0K5o 该链接是为了演示使用事件而不是设置
StatusCode,您应该看到RedirectUri设置为什么。
标签: asp.net-core