473,383 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Accessing Session State across pages

gom
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()
Dec 5 '07 #1
5 1516
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.

"gom" <go*@g.gwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
>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()

Dec 5 '07 #2
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

"gom" wrote:
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()
Dec 5 '07 #3
gom
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.

"Aidy" <ai**@xxnoemailxx.comwrote in message
news:nY******************************@bt.com...
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.

"gom" <go*@g.gwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
>>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()


Dec 5 '07 #4
gom
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?

"Peter Bromberg [C# MVP]" <pb*******@yahoo.NoSpamMaam.comwrote in message
news:F3**********************************@microsof t.com...
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

"gom" wrote:
>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()

Dec 5 '07 #5
"gom" <go*@g.gwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
>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()
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
Dec 5 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: ndsoumah | last post by:
hello guys I'm trying to get access to variables I put in a session variable from another page and it fails... here's the exact situation main file page1.php
9
by: Pack Fan | last post by:
I've noticed that session variables will persist on Mac IE even after all browser windows have been closed. One must quit the program to clear the session variables. This presents a security risk...
2
by: adam | last post by:
Having spent nearly 2 years in win forms land the inevitable request came for me to "do some web pages". So being new to this bit of .net and having had a look around I can't see where the best...
0
by: matt | last post by:
I've come across a real problem and am totally stuck as to why this is happening, hoping desperately that someone else has experienced the same thing, and knows a solution! Session state should be...
5
by: Arun | last post by:
Hi, Is it possible to share Session/Application State across different Asp.net webapplication (one in VB.net ) and the other is C# ? If so can you guide me ? -Regards' Arun
10
by: Suresh | last post by:
how to share Session Sharing Across the domain
1
by: Robert Burdick [eMVP] | last post by:
Hello All: I am writing an ASP.NET application that will take the user to PayPal to make some payments. Before going to PayPal, I collect relevant user information and store it in a session...
9
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of...
4
by: Sam | last post by:
I have an asp.net 2.0 app that uses a sitemap, Master Page, and has several content pages. While this feature has simplified the process of creating a data-driven site menu, it does seem to have...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.