我在GLOBAL中加入这段代码.
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if(LoginUser.UserID == null)
{if(HttpContext.Current.User != null  && 
HttpContext.Current.User.Identity.IsAuthenticated && 
HttpContext.Current.User.Identity is FormsIdentity){
HttpCookie ck = Context.Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName];
System.Web.Security.FormsAuthenticationTicket tk = FormsAuthentication.Decrypt(ck.Value);

UserSQL usql = new UserSQL(); DataSet ds = usql.LoginUser("uc",User.Identity.Name);/////////////////////自定义类中的值赋值/////////////////////////////
LoginUser.UserName = ds.Tables[0].Rows[0]["user_name"].ToString();
LoginUser.UserID = ds.Tables[0].Rows[0]["user_id"].ToString();
LoginUser.UserPop = ds.Tables[0].Rows[0]["user_popedom"].ToString();string[] roles = ds.Tables[0].Rows[0]["UserPop"].ToString().Split('|'); //加入自定义内容
Context.User = new GenericPrincipal(Context.User.Identity,roles);}
}
else
{
string[] roles = LoginUser.UserPop.Split('|');
//Response.Write(roles[1]);
Context.User = new GenericPrincipal(Context.User.Identity,roles);
}}第一次访问网站时提示
行 83:  string[] roles = LoginUser.UserPop.Split('|');
行 84:  //Response.Write(roles[1]);
行 85:  Context.User = new GenericPrincipal(Context.User.Identity,roles);
85行"未将对象引用设置到对象的实例。"
怎么解决呢...在此说一下我的意图. 我用了LoginUser类公有变量保存一些用户资料.
Context.User保存权限.
if(LoginUser.UserID == null)加入这局主要是不加的话他每刷新页面都会访问一次,这样老在打开数据库...