MVC无法重定向到自定义登录URL [重复]

问题描述 投票:0回答:1

我在web.config上设置了以下表单身份验证属性。

 <authentication mode="Forms" >
  <forms loginUrl="~/Account/VerifyCode" timeout="2880">
    <credentials passwordFormat="Clear">
      <user name="admin" password="admin"/>
    </credentials>
  </forms>
</authentication>

但总是在导航到使用[Authorize]属性修饰的控制器时,我总是被重定向到〜/ Account / Login?ReturnUrl =%2FProduct%2FCreate,而不是我在web.config中设置的方法(表示VerifyCode)。

任何人都知道为什么会这样,以及如何将其重定向到我在web.config中指定的方法?

c# asp.net-mvc forms-authentication
1个回答
0
投票

尝试使用以下代码代替代码

<authentication mode="Forms">
  <forms loginUrl="~/Account/VerifyCode" timeout="2880"/>
 </authentication>
© www.soinside.com 2019 - 2024. All rights reserved.