Help understanding httpContext

S

Scooby Dog

Could someone help me with the following:

I have been reading (learning asp.net) the book ASP.net 3.5 for dummies.
In the book chp18 to be exact the author uses HttpContext.Current.profile
and casts that to a ProfileCommon. I understand PostBack and session
Variables, viewstate, and hidden fields but what is 'HttpContext, and
ProfileCommon'. Is HttpContext like some master session thing that both
keeps track of user info ie: ip, login etc and allows you to store data with
in it. Is ProfileCommon a way to write serialized data ie: objects to xml
files or sql databases.

Dim pfile As ProfileCommon

pfile = CType(HttpContext.Current.Profile, ProfileCommon)

pfile.ShoppingCart = New ShoppingCart ' ShoppingCart is a serialized class
with a List(Of cartitems)
pfile.Save()

*********************web.config entry*********************
<profile enabled="true" defaultProvider="AspNetSqlProfileProvider">
<properties>
<add name="ShoppingCart" type="ShoppingCart"
serializeAs="Xml" allowAnonymous="true"/>
</properties>
</profile>
******************************************************



Thanks

Dave
 
G

Guest

Could someone help me with the following:

    I have been reading (learning asp.net) the book ASP.net 3.5 for dummies.
In the book chp18 to be exact the author uses HttpContext.Current.profile
and casts that to a ProfileCommon.  I understand PostBack and session
Variables, viewstate, and hidden fields but what is 'HttpContext, and
ProfileCommon'.  Is HttpContext like some master session thing that both
keeps track of user info ie: ip, login etc and allows you to store data with
in it.  Is ProfileCommon a way to write serialized data ie: objects to xml
files or sql databases.

Dim pfile As ProfileCommon

pfile = CType(HttpContext.Current.Profile, ProfileCommon)

pfile.ShoppingCart = New ShoppingCart ' ShoppingCart is a serialized class
with a List(Of cartitems)
pfile.Save()

*********************web.config entry*********************
<profile enabled="true" defaultProvider="AspNetSqlProfileProvider">
<properties>
<add name="ShoppingCart" type="ShoppingCart"
serializeAs="Xml" allowAnonymous="true"/>
</properties>
</profile>
******************************************************

Thanks

Dave

Dave,

By definition "HttpContext is a class that encapsulates all HTTP-
specific information about an individual Http Request". An HttpContext
object is created when a request is made by user in the browser.

http://msdn.microsoft.com/en-us/library/system.web.httpcontext.aspx

HttpContext includes Application (HttpApplication class) and Session
(HttpSession class) where you can store data.

ProfileCommon is a class which includes properties created from the
profile property definitions specified in the web.config file. More
about ProfileCommon at http://msdn.microsoft.com/en-us/library/2y3fs9xs.aspx

or http://www.odetocode.com/articles/440.aspx

Hope this helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top