配置ASP.NET中使用SQL Server模式的Session State

作者通过亲自试验,完成了在Plesk平台下的SQLServer模式会话状态的配置。具体步骤如下:

  1. 为回话状态建立或是选择相应的数据库Database(Create New Data­ba­se)
  2. 执行会话状态模板SQL语句
    首先进入文件夹C:\Windows\Microsoft.NET\Framework\version_ID\,对于ASP.NET 2.0来说,一般version_ID是v2.0.50727。然后找到InstallSqlStateTemplate.sql,并将文中所有Data­ba­se­Na­me­Pla­ce­Ho­lder替换为你自己的数据库名称,最后将此SQL拖到数据库上执行
  3. 此时也许你会发现,测试SQL语句没问题,但是执行的时候出现了一些问题如下:
    ————————————————-
    Sta­r­ting exe­cu­tion of InstallSqlStateTemplate.SQL
    ————————————————-

    ————————————————–
    Note:                                            
    This file is inclu­ded for backwa­rd compa­ti­bi­li­ty 
    only.  You shou­ld use aspnet_regsql.exe to insta­ll
    and unin­sta­ll SQL session sta­te.                 

    Run ‘aspnet_regsql.exe -?’ for detai­ls.        
    ————————————————–
    If the job does not exi­st, an error from msdb.dbo.sp_delete_job is expe­cted.
    Msg 229, Level 14, Sta­te 5, Pro­ce­du­re sp_delete_job, Line 1
    The EXECUTE per­mi­ssion was denied on the obje­ct ‘sp_delete_job’, data­ba­se ‘msdb’, sche­ma ‘dbo’.
    If the cate­go­ry alrea­dy exi­sts, an error from msdb.dbo.sp_add_category is expe­cted.
    Msg 229, Level 14, Sta­te 5, Pro­ce­du­re sp_add_category, Line 1
    The EXECUTE per­mi­ssion was denied on the obje­ct ‘sp_add_category’, data­ba­se ‘msdb’, sche­ma ‘dbo’.
    Msg 229, Level 14, Sta­te 5, Pro­ce­du­re sp_add_job, Line 1
    The EXECUTE per­mi­ssion was denied on the obje­ct ‘sp_add_job’, data­ba­se ‘msdb’, sche­ma ‘dbo’.

    ————————————————–
    Comple­ted exe­cu­tion of InstallSqlStateTemplate.SQL
    ————————————————–
  4. 不必担心,这个主要是由于用户权限不够而不能将某些规划任务加入到数据库计划中。我们无法将过期的一些session数据删除,不过可以手动操作,或是请求你的主机运营商帮忙

  5. 更新web.config文件:
    <session­Sta­te mode=“SQLServer” allowCustomSqlDatabase=“true” sqlConnectionString=“data source=localhost;initial catalog=数据库名;user id=用用户名;password=密码” cookieless=“false” timeout=“20” />

 

Refe­ren­ce:

You may also like...

Leave a Reply

Your email address will not be published.

13 + 12 =

使用新浪微博登陆