设为首页 收藏本站
查看: 431|回复: 0

[经验分享] 在sharepoint 2010中使用Session

[复制链接]

尚未签到

发表于 2015-9-27 13:45:55 | 显示全部楼层 |阅读模式
  先抄下来记着先http://blogs.msdn.com/b/markarend/archive/2010/05/27/using-session-state-in-sharepoint-2010.aspx
  SharePoint 2010 uses two services related to session state that have similar names but are separate and have different purposes.


  • ASP.NET session state may be used on SharePoint 2010 pages. This service is automatically disabled in normal installations of SharePoint 2010; it may be enabled using the instructions below. Once enabled, it appears on the Service Applications page as “SharePoint Server ASP.NET Session State Service.”
  • The State Service service application is designed for and only available to Office internal components such as InfoPath Forms Services and Visio Services. This service is automatically enabled in typical installations of SharePoint 2010 and is not related to ASP.NET session state. It appears on the Service Applications page as “State Service.”
  To enable ASP.NET session state:


  • Enter the following PowerShell command in the SharePoint 2010 Management Shell window:
    Enable-SPSessionStateService –DefaultProvision
  • On each web application for which you want to use session state, edit the web.config file and set the enableSessionState property of the pages element as follows:
    <pages enableSessionState="true"
  Guidelines for using SharePoint Server ASP.NET Session State:


  • This session state may be used by custom code in web parts and other page-hosted controls.
  • Session state information is stored in a configurable SQL database; this implies the following:

    • Load-balancer affinity is not required.
    • Heavy use of session state must be included in database/capacity planning. By default, the session state database is created on the same database server hosting the SharePoint 2010 farm configuration database. This can be changed to place it on another server; this can be done at a later date if necessary. To move it to another SQL server, it should first be disabled, then enabled again with different configuration that points to the other server.

  • When enabled, Session state is available to the whole 2010 farm. Each web application can choose to enable it for use on ASP.NET pages (enableSessionState="true").
  • Session state is partitioned using the root URL. This means that different web applications will have different session state objects; a web part can only access the session state object available to it. If host header site collections are used, then different session objects will be used for each site collection (the browser will have multiple session ids in different cookies).
  Additional information about enabling session state:

  Syntax 1

  Syntax 2

  Enable-SPSessionStateService
-DefaultProvision

  Enable-SPSessionStateService
-DatabaseName <String>
[-DatabaseServer <String>]
[-DatabaseCredentials <PSCredential>]

  Additional parameters are not discussed here; use Get-Help Enable-SPSessionStateService –full for more information.
  The Enable-SPSessionStateService cmdlet creates a session state database, installs the ASP.NET session state schema, and updates the Web.config files on the farm to turn on the session state service.
  If the DefaultProvision form of the command is used, all default settings are used. These are:


  • DatabaseName = “SessionStateService_<GUID>”
  • DatabaseServer = the same database server as the SharePoint 2010 configuration database
  • DatabaseCredentials = Integrated Windows Authentication
  If the DatabaseName form of the command is used, then these parameters may be set explicitly. If some of the parameters are not included, they default as above. To set specific credentials for accessing the session state database, note that this allows you to specify a SQL Authentication credential only, not a Windows credential. Then, use the Get-Credential command to create a PSCredential object from a username and password, then use that object as the argument of the DatabaseCredentials parameter.
  After this service is enabled, “SharePoint Server ASP.NET Session State Service” will appear on the Service Applications management page.
  You've already answered this yourself somewhere else on the interweb. :)

<httpModules>  
  <add name="Session" type="System.Web.SessionState.SessionStateModule" />  
</httpModules>

  THEN, you must go into your web application and add the same session state module to the IIS7 managed pipeline.


  •   Open IIS 7 manager, and find your web application.

  •   Double click "Modules" in the IIS section.

  •   Click "Add Managed Module..." on the right hand pane.

  •   In the Add Managed Module dialog, enter "SessionState" or something like that for the name, and choose the following item from the dropdown:

      System.Web.SessionState.SessionStateModule, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a


  After that, session state should be enabled for your web app/web service!

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-119544-1-1.html 上篇帖子: A Comprehensive View of SharePoint 下篇帖子: LINQ to SharePoint 试用感受, 欢迎讨论~
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表