Where is HttpSession ? System.net or System.web?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I'm trying to do a http request and read a http session.
I have looked arond a bit, but I cant find any "HttpSession" object ..

System.net
HttpWebRequest has CookieContainer to read Cookies. .. works fine
Source: http://msdn.microsoft.com/library/d...nethttpwebrequestclasscookiecontainertopic.as
Where/how do I get the Session

System.web:
I found an object called: System.Web.HttpContext and it seems to have all i need.
But I cant instance it. The constructor takes to args: System.Web.HttpRequest and System.Web.HttpResponse.
HttpRequest is no problem i just put in the filename and url and so on.
but HttpResponse takes a TextWriter as arg... doh! what should i put there??! and from where

Summary: I want to a Web Client that supports: HTTPS, Cookies, Sessions... what sould I use
So that i can create my own requests from code..

Cheer
- Anders
 
System.Web.SessionState in the System.Web.dll assembly.

However, you don't need to make any references or any imports statements
when using VS.NET because they are already part of any ASP.NET project.


Anders Carlberg said:
Hi,

I'm trying to do a http request and read a http session.
I have looked arond a bit, but I cant find any "HttpSession" object .. .

System.net:
HttpWebRequest has CookieContainer to read Cookies. .. works fine.
Source: http://msdn.microsoft.com/library/d...ethttpwebrequestclasscookiecontainertopic.asp
Where/how do I get the Session?

System.web:
I found an object called: System.Web.HttpContext and it seems to have all i need. .
But I cant instance it. The constructor takes to args:
System.Web.HttpRequest and System.Web.HttpResponse.
 
Anders said:
Hi,

I'm trying to do a http request and read a http session.
I have looked arond a bit, but I cant find any "HttpSession" object
.. .

System.net:
HttpWebRequest has CookieContainer to read Cookies. .. works fine.
Source:
http://msdn.microsoft.com/library/d...ethttpwebrequestclasscookiecontainertopic.asp
Where/how do I get the Session?

System.web:
I found an object called: System.Web.HttpContext and it seems to have
all i need. .
But I cant instance it. The constructor takes to args:
System.Web.HttpRequest and System.Web.HttpResponse.
HttpRequest is no problem i just put in the filename and url and so
on.. but HttpResponse takes a TextWriter as arg... doh! what should
i put there??! and from where?

Summary: I want to a Web Client that supports: HTTPS, Cookies,
Sessions... what sould I use?
So that i can create my own requests from code..

There is no such thing as HTTP sessions on the client -- it's a serverside
concept (even though it may be stored on the client). So if all you want to
to do is clientside HTTP programming, System.Net is the way to go. That
having been said, you still need to support the serverside to maintain the
session. How you do this depends on the way the serverside implements
sessions:

- Cookie-based sessions are fairly easy to support; just make sure your
initial request has a CookieContainer instance associated with it. Submit
the session cookie issued by the web application with each subsequent
request.

- URL rewriting isn't too hard to support either. Just parse
WebResponse.ResponseUri.PathAndQuery and extract the desired session id.
Attach the session id to your request URI's path or query string with each
subsequent request.

Cheers,
 
Hi Anders,

From your description, I understand that you wants to find the HttpSession
class in ASP.NET.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think there is no such class in ASP.NET. Here is a link you may take a
look.

Persisting the Session with ASP.NET
Sessions in ASP.NET applications work much the same as they do in JSP. In
order for the Web server to differentiate incoming requests, it must give
the requesting browser a unique piece of information (a ticket) that is
presented on subsequent visits. The Web server uses this ticket to retrieve
session information from a durable storage area.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/aspnet-jspmig-sessionmanagement.asp


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
System.Web.SessionState is a namespace:
http://msdn.microsoft.com/library/d...-us/cpref/html/frlrfsystemwebsessionstate.asp

In that namespace there is HttpSessionState class
http://msdn.microsoft.com/library/d...WebSessionStateHttpSessionStateClassTopic.asp

System.Web.SessionState.HttpSessionState is the type of HttpContext.Session
and Page.Session properties which can be accessed on ASP.NET Page or in a
class that is used in web context (has access to the current HttpContext)

HttpContext.Session
http://msdn.microsoft.com/library/d...rlrfsystemwebhttpcontextclasssessiontopic.asp

Page.Session
http://msdn.microsoft.com/library/d...tml/frlrfsystemwebuipageclasssessiontopic.asp
 
Hi again..
Im writing a "win32/console app" not a ASP.Net application... If that helps..
I want to simulate a web browser...

I will take a look at the System.Web..

Thanks.
/Ander
 
Hi Anders.

It seems that you wants to do a client side application. Am I right?
I think the HttpSession object in located at Server side, in the client we
can not access the object.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Anders,

I am writing the post to know if you have any concern on this issue.
If yes, please feel free to post here and I will work on it with you.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top