1

I have Searched and looked to this question and tried this guide as well but could'n solve my problem.

I have started a basic and simple web part i want to save a string variable along the session. while i use Page.Session["SomeName"] = "SomeValue", the debugger rises the error stating the enableSessionState must set to true. i have read about this that i must set it in web.config file but my solution in the visual studio only has app.config file. i don't want to change the sharepoint web.config file manually too.

I also have read this article about Enable-SPSessionStateService and done that. so now i want to do everything problematically. i also came to read about solutions witch suggested ussing currentContext and HttpContext, i use .net framework 3.5 and could'nt find HttpContext.

TL,DR:

How to enable session state in an asp.net c# webpart with .net framework 3.5 for sharepoint 2010.

0

you must not use the session in sharepoint (classic session in memory). By definition SharePoint can use multi-front end server, and the session in memory is not Shared between all the front-end, so you can lost values sotred in the session.... Thats why the session is disable in SharePoint and should not be used.

How ever, if you want to use session in memory, this can be configured in web.config of your farm (in the IIS folder), but its not recommended. Insted, you could use the SQLSession. Have a look Session State Management in SharePoint

Else, it depend of your business but you could use the property bag to store data (but be sur of unique key, and don't forget to delete the entry). Or you can use cookie.

  • i looked at the link you provided, by the way is it possible to configure this SQLSession you mentioned problematically? – yekanchi Apr 24 '18 at 8:29
  • I think you mean programmatically. For answer : I realy don't know, but I think you can. Every thing can be performed programmaticaly with PowerShell or C# ;). Check this : Using Session State in SharePoint 2010 you could automate all this stuf – Nico Apr 24 '18 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.