【发布时间】:2017-03-15 08:05:55
【问题描述】:
我想了解哪种方式拒绝页面访问更安全。我知道其中一种用于文件夹访问。我不需要文件夹。
1.方式
<location path="xfile">
<system.web>
<authorization>
<allow roles="admin"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
或 2。方式
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.User.Identity.IsAuthenticated)
{
Response.Redirect("/Login");
}
else
{
if (User.IsInRole("admin"))
{
// my action
}
else
{
Response.Redirect("/");
}
}
}
为了安全我必须使用文件夹吗? 或者 2. 方式不安全?
【问题讨论】:
标签: asp.net security webforms web-config role