【发布时间】:2014-04-12 07:22:33
【问题描述】:
我尝试在 C# 中进行会话。我刚开始学习一段时间,我被困在这里。我试过的代码:
第一:
Session["Status"] = "hehehe";
结果:
The name 'Session' does not exist in the current context
第二次测试:
HttpContext.Current.Session["Status"] = "hehehe";
结果:
The name 'HttpContext' does not exist in the current context
所以我目前被困在这里,在顶部我正在使用:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
【问题讨论】:
-
您需要添加
using System.Web; -
-1 表示缺乏努力
-
Windows 窗体应用程序中
Session的意义是什么(假设在使用System.Windows.Forms之后)? -
非常感谢@Caleb,这是对的。当它在 cmets tho 中时,我无法接受你的答案:/