Response is not available in this context when creation cookie's
Posted
by Sadegh
on Stack Overflow
See other posts from Stack Overflow
or by Sadegh
Published on 2010-04-03T19:43:03Z
Indexed on
2010/04/03
19:53 UTC
Read the original article
Hit count: 326
asp.net-mvc
hi i defined one class to create cookie by received parameter's from user. when i want to add cookie to context i receive an exception.
My Class
public static class ManageCookies
{
public static void Create(string name, string value)
{
HttpCookie cookie = new HttpCookie(name);
cookie.Value = value;
cookie.Expires = DateTime.Now.AddYears(1);
HttpContext.Current.Response.Cookies.Add(cookie);
}
}
Occured Exception: Response is not available in this context.
© Stack Overflow or respective owner