項目從VS2008轉換為VS2010或 開啟頁面設計所有伺服器控制項都出現
只有在設定檔或 Page 指令中將 enableSessionState 設定為 true 時,才能使用工作階段狀態。還請確保在應用程式配置的 \\ 節中包括 System.Web.SessionStateMod 或自訂工作階段狀態模組
第一次遇到這錯誤所以在網上開始 百度 google 看了不少文章全是修改web.config的 (自我感覺不是設定檔的錯誤)我的所有頁面都繼承說BLL的一個類
BLL中引用了system.web(.net framework 2.0)以為是這裡錯誤了於是把所有 2.0DLL全刪除換成4.0不知為什麼,提示引用成功查看屬性還是2.0.
又開始 搜尋 最近找到原因是 protected override void OnInit(EventArgs e) 如果把override去掉就沒問題。
public class Personal_PageBase : System.Web.UI.Page
{
protected override void OnInit(EventArgs e)
{
if (System.Web.HttpContext.Current != null)
{
System.Web.HttpContext.Current.Session["ComanyName"] = null;
if (System.Web.HttpContext.Current.Session["userName"] == null ||
System.Web.HttpContext.Current.Session["userName"].ToString() == "")
{
System.Web.HttpContext.Current.Response.Redirect("/personal/login.aspx");
return;
}
base.OnInit(e);
}
}
加上這段就沒問題了。