Sharepoint Forum

 
Home » Forum » Sharepoint       Ask a questionRSS Feeds

Session variables, SharePoint Global.asax file

  Asked By: Cierra Navarro         Date: Apr 19, 2010      Category: Sharepoint      Views: 2171
 

My requirement is to pop up a window( with company policies) only the
first time a user logs into sharepoint.
I wrote a C# web application and used session variables, it worked.
Then i wrote a web part application it didnt work because the web part
always run even if the browser is closed.
Then after search and research i came to know that i have to set up
session variable in the global.asax file of the sharepoint. But i'm
not able to find a way to do it. How to set session variables in
global.asax file?

This is my C# web Application page_load event.

private void Page_Load(object sender, System.EventArgs e)
{
if (Session["showPopUp"] == null)
{
Response.Write("Session is not set. Show PopUp <br>");
Response.Write("<script language='JavaScript'> var newwindow;
newwindow=window.open('http://abc.com','mywindow','width=500,height=500');
newwindow.focus();</script>");
// Set the session here
Session["showPopUp"] = "true";
}
else
{
Response.Write("Session is set. Do not show PopUp <br>");
}
}

Tagged:            

 

2 Answers Found

 
Answer #1       Answered By: Kelsie Terrell          Answered On: Apr 19, 2010       

First: read this blog on creating a global.asax on sharepoint

blogs.sqlxml.org/bryantlikes/articles/583.aspx

Second: sessions is disabled in SharePoint, so you have to enable
SessionStateModule under httpModules in web.config located in the
root directory of your site.
Just remove the html comment around the tag <add name="Sessions"
type="System.Web.SessionState.SessionStateModule"/>

 
Answer #2       Answered By: Puneet Shiwde          Answered On: Apr 19, 2010       

I got the thing working...i made it as a web  part. The web part  is on
the first page as hidden....and you are right i had to modify
web.config file  to enable sessions
support.microsoft.com/default.aspx

 
Didn't find what you were looking for? Find more on Session variables, SharePoint Global.asax file Or get search suggestion and latest updates.


Your Answer
  • Answer should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].