protected void Application_PostAuthenticateRequest()
{
HttpCookie authoCookies = Request.Cookies[FormsAuthentication.FormsCookieName];
if (authoCookies != null)
{
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authoCookies.Value);
JavaScriptSerializer js = new JavaScriptSerializer();
User1 user = js.Deserialize<User1>(ticket.UserData);
MyIdentity myIdentity = new MyIdentity(user);
MyPrincipal myPrincipal = new MyPrincipal(myIdentity);
HttpContext.Current.User = myPrincipal; //here
}
}
错误就在最后一行......
这是MyPrincipal课程。
public class MyPrincipal
{
private readonly MyIdentity MyIdentity;
public MyPrincipal(MyIdentity _myIdentity)
{
MyIdentity = _myIdentity;
}
public IIdentity Identity
{
get { return MyIdentity; }
}
public bool IsInRole(string role)
{
return Roles.IsUserInRole(role);
}
}
怎么办?我正在学习本教程
答案 0 :(得分:1)
您的班级GRANT SELECT(id), INSERT(id) ON product TO editor_user;
GRANT SELECT(mytext), UPDATE(mytext), INSERT(mytext), REFERENCES(mytext) ON product TO editor_user;
未能宣布已实施的界面MyPrincipal
:
IPricipal
C#中没有鸭子打字。