对于给定文件夹ASP.NET MVC IIS密码提示 [英] IIS Password prompt for given folder ASP.NET MVC
问题描述
如何配置IIS以提示上?
How can I configure IIS to prompt for passwords on a web application running on ASP.NET MVC in IIS?
我要密码保护视图\\ ApplicationLog \\
文件夹中,从而使浏览器要求用户名和密码,当用户尝试访问该文件夹。
I want to password protect the Views\ApplicationLog\
folder, so that browsers ask for username and password when users try to access this folder.
我怎么能做到这一点?这可以从IIS中直接完成,或者我需要设置在web.config中的东西吗?
How could I accomplish this? Can this be done directly from IIS, or do I need to set something in web.config?
请尽量彻底,我不知道IIS那么好。
Please try to be thorough, I don't know IIS all that well.
推荐答案
如果你使用MVC,你不应该有任何人在你的直接访问任何意见
文件夹在所有。相反,你的控制器
(或他们的行动)将断言任何身份验证。
If you're using MVC, you shouldn't have anyone directly accessing anything under your Views
folder at all. Instead, your Controllers
(or their actions) will assert whatever authentication is required.
在这种特殊情况下,它看起来像你的控制器被命名为 ApplicationLogController
。所以,你会在控制器上增加一个 [授权]
属性如下,它会自动确保任何访问控制方法被授权。
In this specific case, it looks like your controller is named ApplicationLogController
. So you'd add an [Authorize]
attribute on the controller as follows, and it will automatically ensure that anyone accessing the controller methods is authorized.
[Authorize] // You can also do [Authorize(Roles="MyRole,YourRole")], etc...
public class ApplicationLogController : Controller
{
...
}
这篇关于对于给定文件夹ASP.NET MVC IIS密码提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!