我在 global.asax 中有这段代码
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
if (Request.Cookies["mylang"] == null)
{
HttpCookie mylang = new HttpCookie("mylang");
mylang.Value = "fa";
mylang.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(mylang);
Session.Add("mylang", "fa");
}
Thread.CurrentThread.CurrentUICulture = new CultureInfo(Request.Cookies["mylang"].Value);
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.Cookies["mylang"].Value);
Session["mylang"] = Request.Cookies["mylang"].Value;
}
但是当我运行我的网站时,显示以下错误:
请求在此上下文中不可用
为什么?