MVC 表单 LoginUrl 不正确 [英] MVC Forms LoginUrl is incorrect

查看:30
本文介绍了MVC 表单 LoginUrl 不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有表单身份验证的 ASP.NET MVC 3 应用程序.由于某些我看不到的原因,登录重定向 url 是 /Account/Login?ReturnUrl=%2fSecure%2fAction 而不是 /Account/LogOn?ReturnUrl=%2fSecure%2fAction.区别很微妙,它使用/Account/Login 而不是/Account/LogOn.

I have an ASP.NET MVC 3 application with forms authentication. For some reason that I cannot see, the login redirect url is /Account/Login?ReturnUrl=%2fSecure%2fAction instead of /Account/LogOn?ReturnUrl=%2fSecure%2fAction. The difference is subtle, its using /Account/Login instead of /Account/LogOn.

我的 web.config 表单部分是正确的.否则会不会影响登录网址??

My web.config forms section is correct. Would else could possibly affect the login url??

<authentication mode="Forms">
  <forms loginUrl="~/Account/LogOn" timeout="720" />
</authentication>

推荐答案

这是一个已知问题.我的自定义授权属性也有同样的问题.我在网上的某个地方找到了解决方案,不记得在哪里.只需将此添加到 web.config

This is a known issue. I had the same problem with my custom authorize attribute. I found the solution somewhere on the net, can't remember where. Just add this to appSettings in your web.config

<add key="loginUrl" value="~/Account/LogOn" />

注意:这适用于 MVC 3,我没有在以前的版本中尝试过.

Note: This works with MVC 3, I didn't try it with previous versions.

发行说明中找到了它,但似乎他们已经更改了设置忘记更新 RTM 版本的发行说明.

Found it mentioned in release notes, but it seems that they've changed the setting name and forgot to update release notes for RTM version.

这篇关于MVC 表单 LoginUrl 不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆