亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 編程 > ASP > 正文

How to Share Session State Between Classic ASP and

2024-05-04 11:06:31
字體:
來源:轉載
供稿:網友
中國最大的web開發資源網站及技術社區,
asp implementation
the native asp session can only store session data in memory. in order to store the session data to sql server, a custom microsoft® visual basic® 6.0 com object is written to manage the session state instead of using the native session object. this com object will be instantiated in the beginning of each web request and reload the session data from sql server. when the asp script is finished, this object will be terminated and the session state will be persisted back to sql server.

the primary purpose of the visual basic 6 com session object is to provide access to the microsoft® internet information server intrinsic objects. the visual basic 6.0 com session object uses the mysession class of sessionutility assembly to hold the session state, and the sessionpersistence class of sessionutility to load and save session data with sql server. the mysession and sessionpersistence classes are exposed as com objects using the regasm.exe utility. the regasm.exe utility can register and create a type library for the com client to consume framework classes.

the session state information is reloaded during the construction of the object. the constructor (class_initialize) will first retrieve the session cookie, session timeout (sessiontimeout), and database connection string (sessiondsn) from the application object, and create an instance of the class mysession to hold the session data. then the constructor will try to reload the session data from sql server with the given cookie. if the sql server does not have the session information, or the session has been expired, a new cookie will be issued. if the sql sever does return with the session state data, the session state will be stored in the mysession object.

private sub class_initialize()
on error goto errhandler:
    const method_name as string = "class_initialize"
    set mysessionpersistence = new sessionpersistence
    set myobjectcontext = getobjectcontext()
    mysessionid = readsessionid()
    mydsnstring = getconnectiondsn()
    mytimeout = getsessiontimeout()
    myisnewsession = false
    call initcontents
    
    exit sub
errhandler:
    err.raise err.number, method_name & ":" & err.source, err.description
end sub

private sub initcontents()
on error goto errhandler:
    const method_name as string = "initcontents"    
    if mysessionid = "" then
        set mycontentsentity = new mysession
        mysessionid = mysessionpersistence.generatekey
        myisnewsession = true
    else
        set mycontentsentity =
        mysessionpersistence.loadsession(mysessionid, mydsnstring, mytimeout)
    end if
        
    exit sub
errhandler:
    err.raise err.number, method_name & ":" & err.source, err.description
end sub

when the object instance goes out of scope in the script, the destructor (class_terminate) will execute. the destructor will persist the session data using the sessionpersistence.savesession() method. if this is a new session, the destructor will also send the new cookie back to the browser.

private sub class_terminate()
on error goto errhandler:
    const method_name as string = "class_terminate"
    call setdataforsessionid
    exit sub
errhandler:
err.raise err.number, method_name & ":" & err.source, err.description  
end sub

private sub setdataforsessionid()
on error goto errhandler:
    const method_name as string = "setdataforsessionid"
    call mysessionpersistence.savesession(mysessionid,
mydsnstring, mycontentsentity, myisnewsession)
    
    if myisnewsession then call writesessionid(mysessionid)
    
    set mycontentsentity = nothing
    set myobjectcontext = nothing
    set mysessionpersistence = nothing
    exit sub
errhandler:
    err.raise err.number, method_name & ":" & err.source, err.description
end sub
you can download the source code of asp.net sessionutility project, the com session manager, and the demo code by clicking the link at the top of the article.

demo program
the demo program is designed to increment and display a number. regardless of which page is loaded, the number will keep incrementing because the number value is stored in sql server and is shared between classic asp and asp.net.

steps to set up the demo program
create a new database called sessiondemodb.
create the sessstate table (osql.exe –e –d sessiondemodb –i session.sql).
create a new virtual directory called demo.
turn off asp session under the asp configuration tab.
copy the web.config, testpage.aspx, global.asa, testpage.asp, and globalinclude.asp to the virtual directory.
update the dsn string setting in the global.asa and web.config. the session timeout setting is optional. the default is 20 minutes.  
install the sessionutility.dll into the global assembly cache (gacutil /i sessionutility.dll).
expose the sessionutility.dll as a com object using the regasm.exe (regasm.exe sessionutility.dll /tlb:sessionutility.tlb).
copy the sessionmanager.dll to a local directory and use regsvr32.exe to register it (regsvr32 sessionmanager.dll).
grant the iusr_<machine_name> account to have read and execute access to the sessionmgr.dll.
steps to run the demo program
start microsoft® internet explorer.
load the testpage.asp for classic asp. the number "1" should appear in the web page.
click refresh on internet explorer to reload the page. the number should be incremented.
change the url to testpage.aspx for asp.net. the number should keep incrementing.
the same process can be repeated by starting the testpage.aspx page first.
incorporating the com object in an existing asp application
a common practice in developing asp applications is to include a file in the beginning of each script to share common codes and constants. the best way to incorporate the custom session object is to add the instantiation code in the common include file. the last step is simply to replace all reference to the session object with the custom session variable name.

limitation/improvement
this solution will not support an existing asp application that stores a com object in the session object. in this case, a custom marshaler is needed to serialize/deserialize the states in order to use the custom session object. in addition, this solution does not support storing type arrays of the string. with some additional effort, this feature can be implemented by using the microsoft® visual basic® 6.0 join function to combine all of the array elements into a single string before storing it into session object. the reverse can be done using the visual basic 6.0 split function to split the string back to individual array elements. on the .net framework side, the join and split methods are members of the string class.

conclusion
asp.net represents a new programming paradigm and architecture, and offers many advantages over classic asp. although porting from asp to asp.net is not a simple process, the better programming model and improved performance of asp.net will make the conversion process worthwhile. with the exception of storing a com object in the session object, the approach described in this article offers a solution that will make the migration process simpler.

about the author
billy yuen works in northern california at the microsoft technology center silicon valley. this center focuses on the development of microsoft .net framework solutions. he can be reached at [email protected]
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
精品亚洲一区二区三区| 欧美日韩国产一区中文午夜| 久久综合久中文字幕青草| 91精品久久久久久久久久久久久| 亚洲视频一区二区三区| 奇米一区二区三区四区久久| 成人精品一区二区三区电影免费| 国产精品自拍视频| 中文字幕国产精品久久| 在线观看91久久久久久| 成人黄色免费片| 欧美成人h版在线观看| 在线观看91久久久久久| 欧美大片在线免费观看| 国产成人亚洲综合91| 欧美视频中文字幕在线| 日韩风俗一区 二区| 欧美日韩精品中文字幕| 欧美大成色www永久网站婷| 欧美网站在线观看| 日本高清+成人网在线观看| 亚洲aa在线观看| 欧美日韩国产影院| 欧美日韩成人免费| 久久久久这里只有精品| 亚洲免费一级电影| 欧美性生交xxxxx久久久| 久久99热精品| 久久久久久com| 欧洲成人性视频| 国产精品入口夜色视频大尺度| 中文字幕日本欧美| 亚洲精品一区久久久久久| 91免费在线视频网站| 国产成人免费91av在线| 9.1国产丝袜在线观看| 国产美女久久久| 亚洲精品美女网站| 91免费观看网站| 青草成人免费视频| 在线观看欧美日韩国产| 国产一区二区在线免费视频| 欧美壮男野外gaytube| 亚洲一区二区国产| 精品欧美国产一区二区三区| 久久伊人精品一区二区三区| 亚洲网站在线观看| 欧美一级淫片丝袜脚交| 久久久av亚洲男天堂| 中文国产成人精品| 国产在线播放91| 91在线播放国产| 国产精品成人国产乱一区| 欧美制服第一页| 欧美另类交人妖| 亚洲欧美三级伦理| 国产精品永久免费| 亚洲精品不卡在线| 538国产精品一区二区免费视频| 国产97色在线|日韩| 日韩在线视频线视频免费网站| 欧美中文字幕在线观看| 欧美成在线视频| 韩剧1988免费观看全集| www.亚洲一二| 亚洲国产日韩欧美综合久久| 精品无人国产偷自产在线| 久久国内精品一国内精品| 一本大道久久加勒比香蕉| 日韩电影中文 亚洲精品乱码| 欧美性xxxx极品高清hd直播| 国产最新精品视频| 亚洲精品成人久久久| 精品国内产的精品视频在线观看| 少妇高潮久久久久久潘金莲| 日韩中文字幕在线| 亚洲韩国日本中文字幕| 青草青草久热精品视频在线观看| 亚洲一区二区中文字幕| 日韩av影片在线观看| 国产一区二区欧美日韩| 最近2019年中文视频免费在线观看| 亚洲精品国产综合区久久久久久久| 狠狠久久亚洲欧美专区| 中文字幕亚洲色图| 亚洲精品按摩视频| 久久久久国产精品免费| 国产精品极品尤物在线观看| 国产成人精品视频| 亚洲奶大毛多的老太婆| 国产欧美一区二区三区四区| 亚洲一区中文字幕在线观看| 欧美激情区在线播放| 懂色aⅴ精品一区二区三区蜜月| 精品无码久久久久久国产| 欧美精品www在线观看| 午夜精品福利电影| 久久6免费高清热精品| 欧美日韩亚洲一区二区| 久久久久亚洲精品成人网小说| 成人av色在线观看| 91天堂在线视频| 裸体女人亚洲精品一区| 久久久亚洲网站| 日本精品免费观看| 一区二区三区在线播放欧美| 久久久www成人免费精品张筱雨| 成人动漫网站在线观看| 中文字幕精品影院| 国产精品色午夜在线观看| 亚洲国产天堂久久综合网| 日韩av成人在线| 亚洲伊人久久综合| 亚洲第一天堂无码专区| 精品av在线播放| 92版电视剧仙鹤神针在线观看| 亚洲成在人线av| 91亚洲精品在线| 欧美电影电视剧在线观看| 日本亚洲欧美三级| 精品女同一区二区三区在线播放| 国产精品成人va在线观看| 久久久久久中文| 亚洲成人网在线观看| 性色av一区二区三区红粉影视| 97热在线精品视频在线观看| 亚洲曰本av电影| 国产不卡av在线| 亚洲综合在线小说| 中文字幕欧美日韩精品| 亚洲аv电影天堂网| 九九精品视频在线观看| 午夜美女久久久久爽久久| 欧美日韩国产精品一区| 亚洲国产高清自拍| 日韩在线视频二区| 亚洲欧美日韩综合| 久久久91精品| 亚洲人线精品午夜| 久久这里有精品| 97婷婷大伊香蕉精品视频| 麻豆一区二区在线观看| 一区二区成人精品| 亚洲精品少妇网址| 久久成人国产精品| 国产精品影院在线观看| 国产91精品高潮白浆喷水| 国产精品久久国产精品99gif| 91精品久久久久久久久久久| 国产成人91久久精品| 91亚洲va在线va天堂va国| 韩剧1988在线观看免费完整版| 国产欧美精品在线播放| 97香蕉久久超级碰碰高清版| 亚洲欧美日韩国产中文专区| 一区二区三区回区在观看免费视频| 狠狠躁夜夜躁人人爽天天天天97| 成人精品一区二区三区| 国产精品96久久久久久| 亚洲性线免费观看视频成熟| 97超碰蝌蚪网人人做人人爽| 国内精品小视频| 欧美日韩免费网站| 2020欧美日韩在线视频|