Solved

Start a Session

Posted on 2006-11-27
7
276 Views
Last Modified: 2008-02-07
I am working in ASP.Net and want to force a Session start in a PageLoad function. Is there an easy way to do this?
0
Comment
Question by:strickdd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 18019074
Hi strickdd,

enable session for page/site and put into your PageLoad
Session["my_data"] = 'waht_ever';

Regards

!i!
0
 
LVL 28

Author Comment

by:strickdd
ID: 18019145
That would work under normal circumstances but I have session variables set in the Global.asax that I need on this page:

void Session_Start(object sender, EventArgs e)
    {
        Session["SomeSession"] = someData;
    }
0
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 18019170
Hi again strickdd,

>  want to force a Session start in a PageLoad f
so you cannt force Session start because it is already started. You could get the value as

someData = (cast_if_necessary)Session["SomeSession"];

HTH

!i!
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 28

Author Comment

by:strickdd
ID: 18019240
The session is timing out before they get to this page and getting the data does not work in this way. Therefore I have to force the session to re-start.
0
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 18019398
Hi again ivostoykov,

> enable session for page/site and put into your PageLoad
> Session["my_data"] = 'waht_ever';

then do it like this

if(Session["SomeSession"] == null){Session["SomeSession"] = someData;}
else {someData = (cast_if_necessary)Session["SomeSession"];}
HTH

!i!
0
 
LVL 28

Author Comment

by:strickdd
ID: 18020724
I would prefer to force a restart of the session at the application level. I have too many session vars set in the Session_Start event to do this to.
0
 
LVL 5

Accepted Solution

by:
prajapati84 earned 500 total points
ID: 18026427
Try this one... This will help u... (C# code)

Global g = new Global();
String str = g.Session_Start(sender, e).ToString;

For more info, refer these articles...

http://www.tek-tips.com/viewthread.cfm?qid=1301825&page=1
http://p2p.wrox.com/topic.asp?TOPIC_ID=39540

Regards,
Mukesh
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question