Blog Stats
  • Posts - 104
  • Articles - 0
  • Comments - 160
  • Trackbacks - 383

 

Enabling Sessions for ASP.NET Web Parts in Sharepoint Portal 2003

To Enable Session State in Sharepoint Portal 2003 you will need to do couple of amendments in the “Web.Config“ placed at the root of your virtual server. (usually available at C:\Inetpub\wwwroot ).
 
Edit your web config file using any editor. (I use Ultra Edit).
 
1) Enabling SessionStateModule:
Find this tage and enable it: (It is disabled/commented by default) 
         
 
2) Enable SessionState:
Enable session state (Set to true):
        

Programmatically check if the session has been enabled on Sharepoint Server or not:
Develop a Web Part and place the following code to test if the session has been enabled or not. Place the following code in your protected override void RenderWebPart(HtmlTextWriter output) method:
 
output.Write("");

output.Write("");

output.Write("

");

output.Write("

");

output.Write("

");

output.Write("

");

output.Write("

");

try

{

if( this.Page.Session != null && this.Page.Session.Count > 0)

{

if( this.Page.Session["UserPass"] == null)

{

output.Write(SPEncode.HtmlEncode("I dont have the passport for you ... "));

this._linkButton.RenderControl(output);

}

else

{

output.Write(SPEncode.HtmlEncode("Thanks GOD "+this.Page.Session["UserPass"].ToString()+"! you are logged in .."));

}

}

else

{

output.Write(SPEncode.HtmlEncode("I dont have the passport for you ... "));

this._linkButton.RenderControl(output);

}

}

catch(System.Exception exp)

{

output.Write(SPEncode.HtmlEncode("ERROR OCCURED "+exp.Message) );

this._linkButton.RenderControl(output);

}

finally

{

output.Write("

");

output.Write("");

output.Write("");

}

thats it for now.
stay tuned for more!

Hammad Rajjoub,
MVP (Windows Server System - XML Web Services),
User Group Leader - Dot Net Wizards (http://dotnetwizards.blogspot.com),
Chariman UG Relations Committee (
http://inetapakistan.org),
Member Speakers Bureau (
http://mea.ineta.org)

Feedback

# How to Handle One Session Per user

Gravatar hi,
i need to know how to handle single session per user... 5/27/2005 11:44 AM | Salman Niaz

# re: Enabling Sessions for ASP.NET Web Parts in Sharepoint Portal 2003

Gravatar sessions are ment to be per user. please specify if you mean some thing else. 7/29/2005 1:43 PM | Hammad

# re: Enabling Sessions for ASP.NET Web Parts in Sharepoint Portal 2003

Gravatar Suppose I have an Application say abc.com.

On Computer 1, I login to this Application using user id=test, password=testpwd.

Now I go to another Compute 2, and try to log into same application with SAME above credentials.

Then, the Session opened on Compute 1 should be killed/logged off automatically. And new Session should start on Computer 2.

How to implement this???

10/19/2006 12:49 PM | Kiran

# re: Enabling Sessions for ASP.NET Web Parts in Sharepoint Portal 2003

Gravatar Error: "does not contain definition for _linkbutton" 1/15/2008 9:43 AM | phil

Post a comment





 

 

 

Copyright © INETA Pakistan