推奨:ASPは、Webページの更新を防ぎますサーバーの負担を軽減し、ASPはWebページの更新を防止しますsubpreventrefreshtime、isrefreshrefreshtime = 10は更新時間、ユニット(秒)isrefresh = 1防止反復関数、0 = 1 = yesifisrefresh = 1hen if
それを使用する方法、ファイルキャッシュを使用する必要があるページに次のコードを追加します。
<! - #includefile = filecatch.asp->
<%
setMycatch = newCatchFile
myCatch.OverDue = 10 '有効期限を10分に変更します
ifmycatch.catchnow(rev)then
Response.WriteMycatch.CatchData
Response.End
endif
SetMycatch =何もない
%>
filecatch.asp
コンテンツをクリップボードコードにコピーします。
<%
'このファイルは、元のファイルをチェックインしてページのファイルキャッチを実装するために使用されます
'1。ファイルリクエストがポストモードの場合、この機能をキャンセルします
'2。ファイルリクエストには、システム識別キーワードを含めることはできません
classCatchFile
PublicOverDue、Mark、cfolder、cfile 'システムパラメーターを定義します
privateScriptName、scriptPath、serverHost 'server/ページパラメーター変数を定義します
publicCatchData '出力データ
privatesubclass_initialize '初期化関数
'サーバーデータとスクリプトデータを取得します
scriptname = request.servervariables(script_name) '現在のスクリプトの仮想アドレスを認識します
ScriptPath = getScriptPath(false) 'スクリプトの完全なGetアドレスを識別します
serverhost = request.servervariables(server_name) '現在のサーバーのアドレスを特定します
'システムパラメーターを初期化します
期限切れ= 30 'デフォルト30分は失効します
mark = nocatch 'キャッチ要求なしパラメーターはノカッチです
cfolder = getCFolder 'デフォルトのキャッチファイルを定義しますディレクトリ
cfile = server.urlencode(scriptpath)&。txt 'スクリプトパスをファイルパスに変換します
catchdata =
Endingub
privateFunctionGetCFolder
dimfso、cfolder
setFSO = createObject(scripting.filesystemobject) 'fsoオブジェクトを設定します
cfolder = server.mappath(/)&//filecatch/
ifnotfso.folderexists(cfolder)then
fso.createfolder(cfolder)
endif
ifmonth(now())<10then
cfolder = cfolder&/0&month(now())
それ以外
cfolder = cfolder&month(now())
endif
ifday(now())<10then
cfolder = cfolder&0&day(now())
cfolder = cfolder&day(now())
endif
cfolder = cfolder&/
ifnotfso.folderexists(cfolder)then
fso.createfolder(cfolder)
endif
getCfolder = cfolder
setfso =何もない
エンド機能
privateFunctionBytes2bstr(VIN) 'エンコードされた関数を変換します
dimstrreturn、thischarcode、i、next charcode
strreturn =
fori = 1tolenb(vin)
thischarcode = ascb(midb(vin、i、1))
ifthischarcode <&h80then
strreturn = strreturn&chr(thischarcode)
それ以外
NextCharcode = ascb(midb(vin、i+1,1))
strreturn = strreturn&chr(clng(thischarcode)*&h100+cint(nextcharcode)))
i = i+1
endif
次
bytes2bstr = strreturn
エンド機能
publicFunctionCatchNow(Rev) 'ユーザーは、キャッチ操作の処理を開始するように指定します
ifucase(request.servervariables(request_method))= postthen
「それが投稿方法の場合、ファイルキャッチは使用できません
Rev = postメソッドを使用して、ファイルキャッチ機能を使用できません
catchnow = false
それ以外
ifrequest.querystring(mark)<> then
'指定されたパラメーターが空でない場合、リクエストがキャッチを使用できないことを意味します
catchnow = false
それ以外
catchnow = getCatchData(Rev)
endif
endif
エンド機能
privateFunctionGetCatchData(Rev) 'キャッチデータを読み取ります
dimfso、isbuildcatch
setFSO = createObject(scripting.filesystemobject) 'fsoオブジェクトを設定して、キャッチファイルにアクセスします
iffso.fileexists(cfolder&cfile)
dimfile、lastcatch
setFile = fso.getFile(cfolder&cfile) 'CatchFileファイルオブジェクトを定義します
lastcatch = cdate(file.datelastModified)
ifdatediff(n、lastcatch、now())> overduethen
'漁獲時間を超えた場合
isbuildcatch = true
それ以外
isbuildcatch = false
endif
setFile = Nothing
それ以外
isbuildcatch = true
endif
ifisbuildcatchthen
getCatchData = http://www.code-123.com/html/buildcatch(rev) 'キャッチを作成する必要がある場合は、キャッチファイルを作成してキャッチデータを同時に設定する必要がある場合
それ以外
getCatchData = http://www.code-123.com/html/readcatch(rev) 'キャッチを作成する必要がない場合は、キャッチデータを直接読んでください
endif
setfso =何もない
privateFunctionGetScriptPath(ISGET) '要求されたすべてのデータを含むアドレスを作成します
dimkey、fir
getScriptPath = scriptName
fir = true
foreachkeyinrequest.querystring
iffirthen
getScriptPath = getScriptPath&?
fir = false
それ以外
getScriptPath = getScriptPath &&
endif
getScriptPath = getScriptPath&server.urlencode(key)&=&server.urlencode(request.querystring(key)))
次
ifisgetthen
iffirthen
getScriptPath = getScriptPath&?
fir = false
それ以外
getScriptPath = getScriptPath &&
endif
getScriptPath = getScriptPath&server.urlencode(mark)&= yes
endif
エンド機能
'キャッチファイルを作成します
privateFunctionBuildCatch(Rev)
dimhttp、url、結果
sethttp = createObject(microsoft.xmlhttp)
'onerrorresumenext
'Response.WriteserverHost&getScriptPath(true)
http.openget、http://&serverhost&getScriptPath(true)、false
http.send
iferr.number = 0then
catchdata = http://www.code-123.com/html/bytes2bstr(http.responsebody)
それ以外
Rev =作成でエラーが発生しました:&err.description
buildcatch = false
err.clear
endif
callwritecatch
sethttp =何もない
エンド機能
privateFunctionReadCatch(Rev)
readcatch = ireadcatch(cfolder&cfile、catchdata、rev)
エンド機能
privatesubwritecatch
Dimfso、tso
setFSO = createObject(scripting.filesystemobject) 'fsoオブジェクトを設定して、キャッチファイルにアクセスします
sttso = fso.createTextfile(cfolder&cfile、true)
tso.write(catchdata)
sttso =何もない
setfso =何もない
Endingub
エンドクラス
functionireadcatch(ファイル、データ、rev)
Dimfso、tso
setFSO = createObject(scripting.filesystemobject) 'fsoオブジェクトを設定して、キャッチファイルにアクセスします
'onerrorresumenext
sttso = fso.opentextfile(file、1、false)
データ= http://www.code-123.com/html/tso.readall
iferr.Number <> 0then
Rev =読み取りでエラーが発生しました:&err.description
readcatch = false
err.clear
それ以外
iReadcatch = true
endif
sttso =何もない
setfso =何もない
エンド機能
%>
共有:ASPコールC#コンパイルされたCOMコンポーネントの例1新しいクラスライブラリの作成mytestdll 2プロジェクトを右クリックmytestdll-》属性 - com相互運用性登録として生成3 Open Assemblyinfo.csファイル変更[アセンブリ:comvisible:comvisible(true)] bisualsutdio2008のコマンドプロンプトラインツールを開きます。