2009-11-22 33 views
16

Yani msdn ve diğer öğreticiler olarak karıştırıldığından, HttpCookies kullanarak Response.Cookies.Add (çerez) aracılığıyla çerez eklemek için kullanmamı söylüyorum. Ama sorun bu. Response.Cookies.Add sadece Çerezler kabul eder ve yok HttpCookies ve bu hatayı alıyorum:HttpCookie ve Çerez arasındaki fark?

Tepki arasındaki fark ne 'System.Net.Cookie' Ayrıca

için 'System.Net.CookieContainer' dan dönüştüremezsiniz .Cookies.Add (çerez) ve Request.CookieContainer.Add (çerez)?

Yardımlarınız için şimdiden teşekkür ederim, C# kullanarak kendimi öğretmeye çalışıyorum.

// Cookie 
Cookie MyCookie = new Cookie(); 
MyCookie.Name = "sid"; 
MyCookie.Value = SID; 
MyCookie.HttpOnly = true; 
MyCookie.Domain = ".domain.com"; 

// HttpCookie 
HttpCookie MyCookie = new HttpCookie("sid"); 
MyCookie.Value = SID; 
MyCookie.HttpOnly = true; 
MyCookie.Domain = ".domain.com"; 

Response.Cookies.Add(MyCookie); 

cevap

13

System.Net.HttpWebResponse kullanıyorsunuz. Ancak yukarıdaki örnek, System.Web.HttpCookie parametresini parametre olarak alan System.Web.HttpResponse kullanır.

Scott Allen

System.Web.HttpRequest is a class used on the server and inside an ASP.NET application. It represents the incoming request from a client.

System.Net.HttpWebRequest is a class used to make an outgoing request to a web application.

+2

Peki nasıl bir isteğin geldiği kimlik doğrulama tanımlama kapmak yok edilir sonraki soru giden isteğine geçmek? – Blairg23