c# - MVC 无法重定向到自定义登录 url
问题描述
我在 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 中设置的方法(表示验证代码)。
任何人都知道为什么会这样,以及如何将其重定向到我在 web.config 中指定的方法?
解决方案
试试下面的代码而不是你的代码
<authentication mode="Forms">
<forms loginUrl="~/Account/VerifyCode" timeout="2880"/>
</authentication>
推荐阅读
- file - 在目录中查找重复文件
- excel - 使用 VBA 查找和替换连续单元格中的值
- c - 在 FINTEK F81866A 芯片组上编程 GPIO 引脚
- hadoop - Hadoop权威指南的面向列的格式章节中的序列顺序?
- ruby - 自定义 Ruby on rails 验证错误
- kubernetes - Unabel 使用 openstack-helm 图表在 kubernetes 上部署 mariadb
- javascript - Marvel API 和 Insomnia(或 Postman):如何传递所需的哈希值?
- node.js - 你如何使用 distinct 和 mockingoose?
- python - 检查我的观点是否在我的屏幕的一部分
- c++ - 如何使用 break 停止循环?