uyuşturmak için HttpContext.Current sınıfının Application özelliği olan HttpApplicationState nesnesine bir değer eklemeye çalışıyorum. Aşağıdaki kodu.NET bir birim testi için HttpContext nesnesini
TextWriter tw = new StringWriter();
HttpWorkerRequest wr = new SimpleWorkerRequest("/webapp", @"path...", "logon.asp", "", tw);
HttpContext.Current = new HttpContext(wr);
//I try the following 2 lines
HttpContext.Current.Application["KeyValue"] = "myValue";
HttpContext.Current.Application.Add("KeyValue", "myValue");
var count = HttpContext.Current.Application.Count;
var get1 = HttpContext.Current.Application["KeyValue"];
var get2 = HttpContext.Current.Application.Get("KeyValue");
ile deneyin Ama HttpContext.Current.Application.Count daima sıfırdır. Değerler
ile yanlış yapmıyor muyum?
aslında. Bu sınıflar, .NET 4 – Bob
için tamam. Onlar da 3.5 var. – bluevoodoo1
ah sensiz. Hala çalışıyor olsa sorun yaşıyor. HttpContext, HttpContextBase'den miras almaz, bu yüzden kendi sınıfımı oluşturamıyorum ve onu kullanamıyorum veya bir şeyi özlüyorum mu? Uygulamanızda – Bob