Solved

Start a Session

Posted on 2006-11-27
7
274 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…

808 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