[英]ASP.NET MVC Authentication Redirect to Login Page when user route to the critical area
I have an intranet application using windows authentication that works great. 我有一个使用Windows身份验证的Intranet应用程序,效果很好。 Now I have a requirement to expose an Admin area.
现在,我需要公开一个“管理”区域。 This area should go to login page and get user password again.
该区域应进入登录页面并再次获取用户密码。
Like when you are already logged into your Google account or your Facebook account and you need to re-enter your password when routing to a critical area. 就像您已经登录到Google帐户或Facebook帐户一样,当您路由到关键区域时需要重新输入密码。
This is an example of my application structure: 这是我的应用程序结构的一个示例:
-IntranetApp
--Controllers
--Admin Areas
----Area1
----Area2
--Special Users Area
----Area1
----Area2
Thank you very much indeed for any help/pointers. 确实非常感谢您的帮助/指标。 Now, I want to develop the mentioned code to my App using Asp.net MVC3?
现在,我想使用Asp.net MVC3将提到的代码开发到我的App中吗?
Here are a few examples: 这里有一些例子:
When you are already logged into your Google account and you want to delete your account for security reasons Google asks you to re-enter your password. 当您已经登录到Google帐户,并且出于安全原因要删除帐户时,Google会要求您重新输入密码。
Please log into your Google account, then go to Edit 2-step Verification 请登录您的Google帐户,然后转到“ 修改两步验证”
Would you mind helping me with this, please? 您能帮我解决这个问题吗?
What about using Roles? 那使用角色呢?
eg 例如
[Authorize(Roles="admin")]
public ActionResult Create() {
...
}
Guru Gu has a good post about it , from the NerdDinner application. Guru Gu在NerdDinner应用程序中有一篇很好的文章 。
In Asp.net MVC applications which use SQL Authentication via asp.net membership provider you can set the authentication for any controller or action by decorating it with Authorize attribute as Pure.Krome explained. 在通过asp.net成员资格提供程序使用SQL身份验证的Asp.net MVC应用程序中,您可以通过使用Pureize.Krome说明的Authorize属性装饰任何控制器或操作来设置身份验证。
But for Creating an Intranet Site Using ASP.NET MVC, I would suggest to follow this MSDN article . 但是对于使用ASP.NET MVC创建Intranet站点,我建议遵循此MSDN文章 。 It's a nice article explaining utilizing windows authentication
这是一篇很好的文章,解释了如何利用Windows身份验证
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.