Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Session variables, SharePoint Global.asax file

  Asked By: Cierra    Date: Apr 19    Category: Sharepoint    Views: 5543

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;
// Set the session here
Session["showPopUp"] = "true";
Response.Write("Session is set. Do not show PopUp <br>");



2 Answers Found

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

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


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"

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

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

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