Asp.net路径访问
Asp.net Path Access
我想了解哪种方式更安全地拒绝页面 access.I 知道其中一种用于文件夹 access.I 不需要文件夹。
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. 方式不安全 ?
<location path="myPage.aspx">
<system.web>
<authorization>
<allow roles="admin"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
我想了解哪种方式更安全地拒绝页面 access.I 知道其中一种用于文件夹 access.I 不需要文件夹。
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. 方式不安全 ?
<location path="myPage.aspx">
<system.web>
<authorization>
<allow roles="admin"/>
<deny users="*"/>
</authorization>
</system.web>
</location>