Solved

Start a Session

Posted on 2006-11-27
7
271 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
  • 3
  • 3
7 Comments
 
LVL 22

Expert Comment

by:Ivo Stoykov
Comment Utility
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
Comment Utility
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
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 28

Author Comment

by:strickdd
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now