Did you got the following error when using session state in SharePoint 2010?
"Session state can only be used when enableSessionState is set to true,
either in a configuration file or in the Page directive. Please also make
sure that System.Web.SessionStateModule or a custom session state module"
I have the solution for you. you have to add SessionStateModule to your site's web.config file as follows :
1.Open IIS 7 manager and find your web application.
2.Double click "Modules" in the IIS.
3.Click "Add Managed Module" on the right side.
4.In the Add Managed Module dialog, enter "SessionState" or any name you like, and choose the following assembly from the dropdown:
System.Web.SessionState.SessionStateModule, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
enjoy !
Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts
Tuesday, April 6, 2010
Monday, April 5, 2010
Unable to open FBA (Form Based Authentication) Site from SharePoint Designer
There are two ways to open FBA Site from SD :
1. Authenticate from IE First : Open your FBA site from IE, Login as Administrator and choose to "Login Automatically" , then open the site from SharePoint Designer. The SharePoint Designer will uses the authentication cookie to open your FBA site.
2. Extend your FBA site from the central administrator. this will create another IIS website with a windows authentication by default. open the site using SD by providing the windows auth. URL of your site.
1. Authenticate from IE First : Open your FBA site from IE, Login as Administrator and choose to "Login Automatically" , then open the site from SharePoint Designer. The SharePoint Designer will uses the authentication cookie to open your FBA site.
2. Extend your FBA site from the central administrator. this will create another IIS website with a windows authentication by default. open the site using SD by providing the windows auth. URL of your site.
Sunday, December 27, 2009
HttpContext & SPContext is always null when Uploading Multiple document libraryin sharepoint
HttpContext & SPContext is always null when Uploading Multiple document libraryin sharepoint : I'm tring to get a value from the session and update a custom field when uploading multiple documents to my sharepoint document library.
I faced an issue when I was tring to update some custom fields of my document library when uploading multiple documents, the field was ( ProjectID ) which I put it inside a session in my custom webpart (the step before uploading the documents).
What I did is : I put the projectID into the cache ( per user which acts as a session) inside the custom webpart as follows :
if (Request.QueryString["ProjectID"] != null)
{
HttpRuntime.Cache.Remove(SPContext.Current.Web.CurrentUser.LoginName);
HttpRuntime.Cache.Add(SPContext.Current.Web.CurrentUser.LoginName, ProjectID, null, DateTime.UtcNow.AddMinutes(60), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
}
then I implemented the ItemAdded event and I get the value of the cached projectId through :
Note that I get the cached key through the created by field which is the same key name that I cached it from inside my custom webpart.
public override void ItemAdded(SPItemEventProperties properties)
{
try
{
string ProjID = "";
string CreatedBy = null;
if (properties.ListItem["Created By"] != null)
CreatedBy = properties.ListItem["Created By"].ToString().Split(';')[1].Replace("#","");
if (HttpRuntime.Cache[CreatedBy] != null)
{
//SPContext.Current.Web.CurrentUser.LoginName;
ProjID = HttpRuntime.Cache[CreatedBy].ToString();
if (properties.ListItem["Project"] == null)
{
properties.ListItem["Project"] = new SPFieldLookupValue(ProjID);
properties.ListItem.SystemUpdate();
}
base.ItemAdded(properties);
}
}
catch (Exception ex)
{ }
}
Regards,
Mohammed Barakat Kharboush
I faced an issue when I was tring to update some custom fields of my document library when uploading multiple documents, the field was ( ProjectID ) which I put it inside a session in my custom webpart (the step before uploading the documents).
What I did is : I put the projectID into the cache ( per user which acts as a session) inside the custom webpart as follows :
if (Request.QueryString["ProjectID"] != null)
{
HttpRuntime.Cache.Remove(SPContext.Current.Web.CurrentUser.LoginName);
HttpRuntime.Cache.Add(SPContext.Current.Web.CurrentUser.LoginName, ProjectID, null, DateTime.UtcNow.AddMinutes(60), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
}
then I implemented the ItemAdded event and I get the value of the cached projectId through :
Note that I get the cached key through the created by field which is the same key name that I cached it from inside my custom webpart.
public override void ItemAdded(SPItemEventProperties properties)
{
try
{
string ProjID = "";
string CreatedBy = null;
if (properties.ListItem["Created By"] != null)
CreatedBy = properties.ListItem["Created By"].ToString().Split(';')[1].Replace("#","");
if (HttpRuntime.Cache[CreatedBy] != null)
{
//SPContext.Current.Web.CurrentUser.LoginName;
ProjID = HttpRuntime.Cache[CreatedBy].ToString();
if (properties.ListItem["Project"] == null)
{
properties.ListItem["Project"] = new SPFieldLookupValue(ProjID);
properties.ListItem.SystemUpdate();
}
base.ItemAdded(properties);
}
}
catch (Exception ex)
{ }
}
Regards,
Mohammed Barakat Kharboush
Subscribe to:
Posts (Atom)