Google で多くの調査を行った結果、問題の解決策が見つかりませんでした。
セッション変数に値を入力させたい場合は、すべて問題ありません。
Session["idResult"] = youthID;
しかし、ラインコードで値を取得したい場合:
youthID = (int)Session["idResult"];
エラーが表示されます:
セッション状態は、構成ファイルまたは Page ディレクティブで enableSessionState が true に設定されている場合にのみ使用できます。また、System.Web.SessionStateModule またはカスタム セッション状態モジュールが<configuration>\<system.web>\<httpModules>
アプリケーション構成のセクションに含まれていることを確認してください。
私は web.config に追加しようとしました: EnableSessionState="True"
また:
<httpModules><add name="Session" type="System.Web.SessionState.SessionStateModule"/> </httpModules>
<pages enableSessionState="true"/>
および他の多くの可能性がありますが、機能しません
私のデフォルトのweb.configは次のとおりです。
> <?xml version="1.0"?> <!-- For more information on how to configure
> your ASP.NET application, please visit
> http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration>
> <system.web>
> <compilation debug="true" targetFramework="4.5"/>
> <httpRuntime targetFramework="4.5"/> </system.web> </configuration>