Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Accessing Session State across pages

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gom - 05 Dec 2007 17:12 GMT
I am an amatuer asp.net programmer so I hope this question isn't to dumb.

I am having difficulty with my understanding of session state.  I have an
application that stores some values in the session and then I use the
following code to try and get a stream of image data.  mypage.aspx has a
different session ID then the calling page.  I tried to use a relative URI
but the getresponse said it couldn't use a relative uri.  I've looked at
cookie containers but can't quite seem to make them work.  I thought that
session variables would be available to all pages in my app but I'm thinking
that the code below must somehow create, almost like a new instance of
something that gets it's own session ID.  Can anyone suggest what I am
missing or where I am going wrong?

Thanks in advance for any help.

Dim myURI As New Uri(http://mysite.com/myapp/mypage.aspx)
Dim myRequest As System.Net.HttpWebRequest =
System.Net.WebRequest.Create(myURI)
Dim myResponse As System.Net.HttpWebResponse = myRequest.GetResponse
Dim responseStream As System.IO.Stream = myResponse.GetResponseStream()
Aidy - 05 Dec 2007 17:21 GMT
Your asp.net code calling mypage.aspx will have its own session, separate
from the one the client on a remote machine has from the asp.net site.  This
is by design.  What is mypage.aspx doing?  Maybe you can re-architect it.

>I am an amatuer asp.net programmer so I hope this question isn't to dumb.
>
[quoted text clipped - 16 lines]
> Dim myResponse As System.Net.HttpWebResponse = myRequest.GetResponse
> Dim responseStream As System.IO.Stream = myResponse.GetResponseStream()
gom - 05 Dec 2007 17:33 GMT
It is using some session variables, created by the calling page, to modify
an image and then return it.  If I embed an imagecontrol in the calling page
I can pass mypage.aspx and it gets the image modified by my session state
data.  I want to get that same image back but in a responsestream.  I can
see what you are saying about client vs server.  I was sort of seeing that
as what was wrong but my understanding is still limited.  Is there a better
way to create and store this data for use in a session?  Cookies?  Any
examples on the web you can point me to?

Thanks for your help.

> Your asp.net code calling mypage.aspx will have its own session, separate
> from the one the client on a remote machine has from the asp.net site.
[quoted text clipped - 21 lines]
>> Dim myResponse As System.Net.HttpWebResponse = myRequest.GetResponse
>> Dim responseStream As System.IO.Stream = myResponse.GetResponseStream()
Peter Bromberg [C# MVP] - 05 Dec 2007 17:29 GMT
The problem you have here is that you aren't requesting a page in the normal
way one would navigate a web site, in which case the SessionID cookie would
automatically be transmitted by the browser. What you are doing is
programmatically requesting a page via the HttpWebRequest / Response classes.

if all this does is get an image, what do you need Session for? You cannot
attach Session to something requested over http in this manner.
-- Peter
Site: www.eggheadcafe.com 
UnBlog: petesbloggerama.blogspot.com
Metafinder: www.blogmetafinder.com

> I am an amatuer asp.net programmer so I hope this question isn't to dumb.
>
[quoted text clipped - 16 lines]
> Dim myResponse As System.Net.HttpWebResponse = myRequest.GetResponse
> Dim responseStream As System.IO.Stream = myResponse.GetResponseStream()
gom - 05 Dec 2007 17:45 GMT
I believe I have caused a problem for myself by trying to extend some code
in the wrong fashion.  mypage.aspx was first used to get an image and show
it in an imagecontrol.  Now I just want the response stream.  I probably
should just write a function or sub that does what mypage.aspx does and use
it to get my image data.  That way it is all happening on the server.

Does that make sense?

> The problem you have here is that you aren't requesting a page in the
> normal
[quoted text clipped - 33 lines]
>> Dim myResponse As System.Net.HttpWebResponse = myRequest.GetResponse
>> Dim responseStream As System.IO.Stream = myResponse.GetResponseStream()
Bjorn Sagbakken - 05 Dec 2007 17:55 GMT
>I am an amatuer asp.net programmer so I hope this question isn't to dumb.
>
[quoted text clipped - 16 lines]
> Dim myResponse As System.Net.HttpWebResponse = myRequest.GetResponse
> Dim responseStream As System.IO.Stream = myResponse.GetResponseStream()

I may be missing what you are trying to accieve, but if I wanted to transfer
a stream of image data from one form to another, I would do it like this:

Dim myStream as Stream
' add your data to myStream here
Session("myStream")=myStream '//here the stream is stored in as session
variable called myStream

In the other form you just retrieve this stream of data the opposite way:
Dim myStream as Stream=Session("myStream")

Very easy. I use it a lot.

Bjorn

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.