Asp.net mvc vNext重定向到登录返回404
我使用的是vNext,它在本地主机上运行良好,但在服务器上,重定向到登录功能确实会将我发送到正确的url(XXX/Account/login?ReturnUrl=%2FMonitoring),但我收到一条错误消息Asp.net mvc vNext重定向到登录返回404,asp.net-mvc,iis,Asp.net Mvc,Iis,我使用的是vNext,它在本地主机上运行良好,但在服务器上,重定向到登录功能确实会将我发送到正确的url(XXX/Account/login?ReturnUrl=%2FMonitoring),但我收到一条错误消息 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailabl
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
方法:
[HttpGet]
[AllowAnonymous]
public IActionResult Login(string returnUrl)
{
ViewBag.ReturnUrl = returnUrl;
return View();
}
Startup.cs
app.UseCookieAuthentication(options =>
{
options.AutomaticAuthenticate = true;
options.AutomaticChallenge = true;
options.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.CookieName = "WnctAuthCookie";
if (!env.IsDevelopment())
options.CookieSecure = CookieSecureOption.Always;
options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
options.SlidingExpiration = true;
options.LoginPath = new PathString("/Account/Login");
options.LogoutPath = new PathString("/Account/Logout");
});
我使用的是1.0.0-rc1-final
,我还在Windows 7下使用IIS 7.5,并且启用了https
我不确定这是由于IIS设置还是其他原因造成的。有人有解决方案吗?我不确定,但我认为您必须输入文件名,其扩展名如下所示
options.LoginPath = new PathString("/Account/Login.aspx");
options.LogoutPath = new PathString("/Account/Logout.aspx");
登录后是否直接导航到“/Monitor”work?@Thorarins,否则它将重定向到login并返回404,因此它无法找到登录名?@Thorarins login工作,但不使用returnUrl,然后返回404。您可以在github上发布复制吗?问题似乎是它没有重定向到https