我正在尝试在 Windows 服务应用程序中使用Session["emailcc3"] ..但它向我显示了一个错误会话在此上下文中不可用....有没有其他方法可以做到这一点?
这是我的代码:
foreach (DataRow newRow in employee.Rows)
{
num = num - 1;
if (num == 4)
{
Session["emailto"] = newRow["EMAILID"].ToString();
}
if (num == 3)
{
Session["emailcc1"] = newRow["EMAILID"].ToString();
}
if (num == 2)
{
Session["emailcc2"] = newRow["EMAILID"].ToString();
}
if (num == 1)
{
Session["emailcc3"] = newRow["EMAILID"].ToString();
}
}
string emailto = Session["emailto"].ToString();
string emailcc1 = Session["emailcc1"].ToString();
string emailcc2 = Session["emailcc2"].ToString();
string emailcc3 = Session["emailcc3"].ToString();