Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Start a Session

Posted on 2006-11-27
7
Medium Priority
?
283 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
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

972 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