只有在設定檔或 Page 指令中將 enableSessionState 設定為 true 時,才能使用工作階段狀態。還請確保在應用程式配置的 \\ 節中包括 System.Web.SessionSta

來源:互聯網
上載者:User

項目從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);
            }
        }

加上這段就沒問題了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.