26 Aralık 2009 Cumartesi

Accessing Session objects from library classes in ASP.NET

Problem: When you try to use Session objects in your class libraries you will get the error  "the name 'Session' does not exist in the class or namespace" . Because session is an http object and can be reached in the web context.

Solution: The following line will make make you access session objects if your class is in use as a result of an http request...

HttpContext.Current.Session("MyObject")


Yours sincerely.

Hiç yorum yok:

Yorum Gönder