我有这个代码
if (PreviousPage.IsPostBack)
{
if (Request.Form["username"] == ConfigurationManager.AppSettings["username"] && Request.Form["password"] == ConfigurationManager.AppSettings["password"])
{
Session["username"] = Request.Form["username"];
using (var context = new mallEntities())
{
var countProducts = (from p in context.Products
select p).Count();
var countStores = (from p in context.Stores
select p).Count();
var countCategories = (from p in context.Categories
select p).Count();
Label3.Text = countProducts.ToString();
Label2.Text = countStores.ToString();
Label1.Text = countCategories.ToString();
}
}
else
{
Response.Redirect("Default.aspx?invaild=true");
}
} else if(Session["username"] == null)
{
Response.Redirect("Default.aspx?session=false");
}
我收到了这个错误信息:
Object reference not set to an instance of an object
在PreviousPage.IsPostBack
为什么?
问题是什么?