【发布时间】:2011-02-10 17:35:36
【问题描述】:
我正在尝试保护我的整个 MVC 站点,因此在 Home 控制器之前,我添加了一个 [Authorize] 属性。
现在,如果您从 Visual Studio 运行它或使用根 URL(例如 http://localhost:2897)导航,它会按预期重定向到登录页面。但是重定向后地址栏中的 URL 是这样的:http://localhost:2897/Account/LogOn?ReturnUrl=%2fdefault.aspx%3f
我没有对此进行测试,因为我还没有实现我的身份验证代码。但是,这对我来说似乎是个大问题,因为我的项目中没有 default.aspx!
我在 web.config 中的身份验证标签如下所示:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" defaultUrl="~/Home/Index" timeout="2880"/>
</authentication>
为什么不选择这条路由作为默认的 ReturnUrl 而不是 default.aspx?
【问题讨论】:
标签: asp.net-mvc authentication returnurl