ASP.NET MVC3 的最简单身份验证
我一直坚持简单的事情:(
我有一个带有 /Admin/ URL 的 ASP.NET MVC3 应用程序。我在那里放置了 [Authorize] 属性,这样就可以了。但现在我需要简单的事情:只是限制对它的访问只有一个用户名/密码。
我不想使用 ASP.NET 表单授权创建数据库,并且需要它在我的开发 PC 上使用 Visual Studio 和 IIS7 服务器
来快速完成此操作 。放到web.config 使其与“admin/p4ssw0rd”对一起工作?
I've stuck with simple thing :(
I have an ASP.NET MVC3 app with /Admin/ URL. I put [Authorize] attribute there, it's OK with that. But now I need simple thing: just to limit access to it with only one username/password.
I don't want create database with ASP.NET forms authorization, and I need it to work on my development PC with Visual Studio, and IIS7 server.
What's the best way to do this fast? What I have to put to web.config to make it work with "admin/p4ssw0rd" pair?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅:这个问题
您可以明确指定您的用户名和密码(如果您希望使用纯文本密码,请注意解决方案。
see: this question
You can specify your username and password explicitly (please note the solution if you wish to use the password in plain text.
当您创建 ASP.NET MVC 3 应用程序时,Visual Studio 添加了一个
AccountController
。只需修改 LogOn 操作,即可手动执行验证,而不是在数据库中查找:When you created the ASP.NET MVC 3 application, Visual Studio added an
AccountController
. Simply modify the LogOn action so that instead of looking in database you perform the verification manually: