1、
HttpCookie cookie = new HttpCookie("userName");
cookie.Value = userName;
HttpContext.Current.Response.Cookies.Add(cookie);
2、
HttpContext.Current.Response.Cookies["userName"].Value = userName;
请问我以上两种写法有什么区别,第一种写法在我的程序里面会报错:
“    服务器无法在发送 HTTP 标头之后修改 cookie”
第二种则不会报错,为什么?