My initial thoughts were that the HTTPContext object would
not be in scope in a middle tier object method, hence
passing individual session values as method parameters. Is
this correct?
Here is a subset of the sample I knocked up to test this
scenario:
public string GetTypes()
{
using System.Web;
StringBuilder sb = new StringBuilder();
sb.Append(HttpContext.Session["UserID"].ToString());
return(sb.ToString());
}
The following message is generated:
An object reference is required for the nonstatic field,
method, or property 'System.Web.HttpContext.Session'.
Do I need to pass the HTTPContext object to the middle
tier object through a method parameter?
>-----Original Message-----
>You could just use the HttpContext object from your
business tier.
>Or if you want your business objects to be more generic
so they could be
>used from other (non-web) front ends in the future then
you may just want to
>only pass value types as parameters to your business
objects. In this case
>your page objects would extract the necessary information
from session state
>so the business objects don't need to deal with any web
stuff.
>
>--
>I hope this helps,
>Steve C. Orr, MCSD, MVP
>http://Steve.Orr.net
>Hire top-notch developers at http://www.able-
consulting.com
>
>
>
>"Glenn" <> wrote in
message
>news:036c01c3d4aa$6f2db0a0$...
>> Hi,
>>
>> I know that I can access session state on an asp.net
page
>> using either HttpContext or Page objects, but how do I
>> access session data from middle tiers?
>>
>> Should the technique be to extricate the necessary
session
>> data with a web page and pass this to the business tier?
>>
>> If I need to alter session state in a middle tier
object,
>> should I use a reference parameter and update the
session
>> state when the method call is complete?
>>
>> Thanks,
>>
>> Glenn.
>
>
>.
>