给执行代码加 执行权限 角色管理[System.Security.Permission]
更多详细:http://weblogs.asp.net/scottgu/archive/2005/11/14/430598.aspx
public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Authors aucmd = new Authors();
Response.Write(aucmd.pvHello());
}
}
//[PrincipalPermission(SecurityAction.Demand, Authenticated = true)]
public class Authors
{
// Methods
[PrincipalPermission(SecurityAction.Demand, Role = "Admin")]
public string pvHello()
{
return DateTime.Now.ToString();
}
}
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Authors aucmd = new Authors();
Response.Write(aucmd.pvHello());
}
}
//[PrincipalPermission(SecurityAction.Demand, Authenticated = true)]
public class Authors
{
// Methods
[PrincipalPermission(SecurityAction.Demand, Role = "Admin")]
public string pvHello()
{
return DateTime.Now.ToString();
}
}