【发布时间】:2013-12-29 17:14:42
【问题描述】:
我在 global.asax.cs 应用程序启动中使用了Http.Current.Response。当我在我的电脑上执行时,它工作正常,没有任何问题。但是当我尝试将它放入带有 Windows Server 2008 R2 的 IIS 时,我发现它给出了以下错误。
它的代码是
public static void SetCookie(string key, string value, int dayExpires)
{
HttpCookie encodedCookie = HttpSecureCookie.Encode(new HttpCookie(key, value));
encodedCookie.Expires = DateTime.Now.AddDays(dayExpires);
HttpContext.Current.Response.Cookies.Remove(key);
HttpContext.Current.Response.Cookies.Add(encodedCookie);
}
我想找出为什么它会在我的系统中执行,而不是在 IIS 中。
谢谢
【问题讨论】:
-
在Application_Start()中调用
标签: c# iis response global-asax httpcontext