9 Replies - 2724 Views - Last Post: 23 August 2010 - 06:45 AM Rate Topic: -----

#1 Frinavale   User is offline

  • D.I.C Addict
  • member icon

Reputation: 205
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Session shared between pages in Page to Page request

Posted 19 August 2010 - 01:18 PM

My application is simple, I have 2 pages:
  • RSSProducer.aspx
    • A page that generates RSS (XML) feeds

  • RssConsumer.aspx
    • A page that retrieves the RSS feeds and displays it to the user


My problem is that user-authorization details are stored in session in the RssConsumer page that need to be accessed in the RSSProducer page; however, the Session identifier is not common between the two. This means that I cannot access the authorization details in the RSSProducer page.

For example this is what I have in my RssConsumer page:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Session("permittedToViewSomeDetail") = True
    Dim url = "http://localhost/DevSite/RSSProducer.aspx"
    Dim reader As New System.Xml.XmlTextReader(url)
    Dim ds As New DataSet()
    ds.ReadXml(reader)
    myRssRepeater.DataSource = ds.Tables(2)
    myRssRepeater.DataBind()
End Sub


I need the ability to access Session("permittedToViewSomeDetail") in the RSSProducer page but I am unable to do so.


The reason for why is fairly clear to me:
  • User's browser makes a request to the RssConsumer page
  • Server generates a Session ID (which is stored in a cookie) if there is no existing Session Identifer
  • The RSSConsumer requests the RSSProducer page...which generates a new Session ID every time because no session identifier is ever going to be found.


I tried using cookieless session so that I could pass the SessionID via the URL to the RSSProducer page as an experiment but for some reason the XmlTextReader doesn't work well with this method (but the desired shared session does work).

I've hit a brick wall here.
Does anyone know how to share session between pages when one page makes a request to the other?

Thanks,

-Frinny

This post has been edited by Frinavale: 19 August 2010 - 01:59 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Session shared between pages in Page to Page request

#2 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1536
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: Session shared between pages in Page to Page request

Posted 20 August 2010 - 07:03 AM

I don't know if this will work or not, but I was reading this post in another thread and thought about your problem.


http://www.dreaminco...ost__p__1095598

Using the cache makes data available across sessions.
Was This Post Helpful? 1
  • +
  • -

#3 Frinavale   User is offline

  • D.I.C Addict
  • member icon

Reputation: 205
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: Session shared between pages in Page to Page request

Posted 20 August 2010 - 07:45 AM

Thanks @eclipsed4utoo, I was staying away from cache because of the nature of this particular RSS feed. I was hoping to use RSS to provide information about live events that are taking place but only show particular information to particular people. In other words, users have to log into a website in order to view the RSS feed...and the website is not using your typical forms authentication either otherwise I won't have this problem.

It's not a typical scenario at all but I wanted to play with RSS since I haven't had the chance before. I didn't realize how truly simple it was until yesterday. The only not-so-simple thing was the Session issue (which I kind of got around with cookieless session...)

I'm taking a new, easier approach for implementing this solution :)

Thanks for your help

-Frinny

This post has been edited by Frinavale: 20 August 2010 - 07:45 AM

Was This Post Helpful? 0
  • +
  • -

#4 Jayman   User is offline

  • Student of Life
  • member icon

Reputation: 423
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Session shared between pages in Page to Page request

Posted 20 August 2010 - 07:53 AM

A much simpler approach is to simply pass the value as a Query string in the URL. Just sayin. :)
Was This Post Helpful? 0
  • +
  • -

#5 Frinavale   User is offline

  • D.I.C Addict
  • member icon

Reputation: 205
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: Session shared between pages in Page to Page request

Posted 20 August 2010 - 08:13 AM

Yeah, I considered that too but the information is a bit much too much be passing via Query string. It's not just a simple variable that I need access to (like in the example I posted)...it's a complex object that I want to retrieve from Session.
Was This Post Helpful? 0
  • +
  • -

#6 skyhawk133   User is offline

  • Head DIC Head
  • member icon

Reputation: 1964
  • View blog
  • Posts: 20,423
  • Joined: 17-March 01

Re: Session shared between pages in Page to Page request

Posted 20 August 2010 - 08:19 AM

hidden form field a possibility? pass large amounts of data from 1 page to the other using POST?
Was This Post Helpful? 0
  • +
  • -

#7 Frinavale   User is offline

  • D.I.C Addict
  • member icon

Reputation: 205
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: Session shared between pages in Page to Page request

Posted 20 August 2010 - 09:07 AM

I'm not sure how I would set the hidden field in the page (the RSSProducer page) that I am requesting...
Was This Post Helpful? 0
  • +
  • -

#8 Jayman   User is offline

  • Student of Life
  • member icon

Reputation: 423
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Session shared between pages in Page to Page request

Posted 20 August 2010 - 02:53 PM

You would set it the value in a HiddenField on the RSSConsumer page, not the RSSProducer page.

Then you could simply loop through the forms in the Request object in the load event of the RSSProducer page storing them in a Session variable.

I had to do this on a site that was developed in classic ASP, but was redirecting to an ASPX page. Since session is not shared, even though its on the same domain, this seemed to work very well.
for (int i = 0; i < Request.Form.Count; i++)
   {
      Session[Request.Form.GetKey(i)] = Request.Form[i].ToString();
   }

Was This Post Helpful? 0
  • +
  • -

#9 Frinavale   User is offline

  • D.I.C Addict
  • member icon

Reputation: 205
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: Session shared between pages in Page to Page request

Posted 23 August 2010 - 06:36 AM

You both seem to be talking about something that is going over my head....

The RSSConsumer page uses a XmlTextReader to retrieve the XML from the RSSProducer page. The RSSProducer page needs to access the user's permissions in order to produce the correct RSS feeds (depending on what the user is permitted to).

The user's permissions are stored in session.

The problem is that the browser requests the RSSConsumer page, and then the RSSConsumer page uses the XmlTextReader to retrieve the XML from the RSSProducer page. Since it is not the browser that is requesting the RSSProducer page, no Session Identifier is detected in the RSSProducer page; therefore, the RSSProducer page creates a new Session ID every request...and cannot access the user's Session.

I know how to retrieve data from HiddenFields, and the URL etc etc...but I still don't understand how a HiddenField is going to help me?

-Frinny
Was This Post Helpful? 0
  • +
  • -

#10 Frinavale   User is offline

  • D.I.C Addict
  • member icon

Reputation: 205
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: Session shared between pages in Page to Page request

Posted 23 August 2010 - 06:45 AM

I just wanted to mention that I have taken another approach to solving this problem: I moved the code responsible for producing the RSS-XML into the RSSConsumer page...which is no longer the RSSConsumer page because I removed the RSS-XML-producing-functionality completely: I am now binding the raw data to the repeater instead of binding RSS-XML to the reapeter.

I still have the project that was using the RSSProducer and RSSConsumer page...I am curious to find out how to get around this issue.

-Frinny

This post has been edited by Frinavale: 23 August 2010 - 06:46 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1