FormsAuthentication LoginUrl

Kye*_*ica 17 asp.net-mvc forms-authentication asp.net-mvc-3

我在这里完全失败了.这工作得早.我有一个使用表单身份验证的MVC3应用程序.在web配置中,我有以下内容:

<authentication mode="Forms">
  <forms loginUrl="~/Login/Index" timeout="2880"/>
</authentication>
Run Code Online (Sandbox Code Playgroud)

但是,出于某种原因,当重定向时,或者在检查FormsAuthentication.LoginUrl时,它仍然使用默认的/ Account/Login.哪个不存在.为什么web.config不会覆盖这个?

fre*_*nky 35

尝试将此添加到appSettings您的web.config:

<add key="loginUrl" value="~/Account/LogOn" />
Run Code Online (Sandbox Code Playgroud)

  • 谢谢.为什么是这样?看起来很奇怪,另一种方法不起作用. (2认同)