日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

asp從緩存讀數(shù)據(jù)實(shí)例_ASP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:asp防止網(wǎng)頁刷新代碼
減輕服務(wù)器負(fù)擔(dān),asp防止網(wǎng)頁刷新代碼 SubPreventRefresh() DimRefreshTime,isRefresh RefreshTime=10防止刷新時(shí)間,單位(秒) isRefresh=1是否使用防刷新功能,0=否,1=是 IfisRefresh=1Then If(NotIsEmpty(Session(RefreshTime)))AndRefreshTime0Then IfDateDiff(s,Se

 

從文件讀數(shù)據(jù),要比直接從數(shù)據(jù)庫快,測試讀出6000條新聞,讀數(shù)據(jù)庫用了23579毫秒,讀文件只用了123毫秒,下例為使用文件緩存的代碼  
使用方法,在需要使用文件緩存的頁面加入下列代碼, 
<!--#include file="FileCatch.asp" --> 
<% 
Set MyCatch=new CatchFile 
MyCatch.Overdue=10     ’修改過期時(shí)間設(shè)置為10分鐘 
if MyCatch.CatchNow(Rev) then 
        response.write MyCatch.CatchData 
        response.end 
end if 
set MyCatch=nothing 

%> 
FileCatch.asp 
復(fù)制內(nèi)容到剪貼板代碼: 
<% 
’ 本文件用于簽入原始文件,實(shí)現(xiàn)對(duì)頁面的文件Catch 
’ 1、如果文件請(qǐng)求為POST方式,則取消此功能 
’ 2、文件的請(qǐng)求不能包含系統(tǒng)的識(shí)別關(guān)鍵字 
Class CatchFile 
        Public Overdue,Mark,CFolder,CFile ’定義系統(tǒng)參數(shù) 
        Private ScriptName,ScriptPath,ServerHost ’定義服務(wù)器/頁面參數(shù)變量 
        Public CatchData        ’輸出的數(shù)據(jù) 
        Private Sub Class_Initialize        ’初始化函數(shù) 
                ’獲得服務(wù)器及腳本數(shù)據(jù) 
                ScriptName=Request.Servervariables("Script_Name") ’識(shí)別出當(dāng)前腳本的虛擬地址 
                ScriptPath=GetScriptPath(false)        ’識(shí)別出腳本的完整GET地址 
                ServerHost=Request.Servervariables("Server_Name") ’識(shí)別出當(dāng)前服務(wù)器的地址
                ’初始化系統(tǒng)參數(shù) 
                Overdue=30        ’默認(rèn)30分鐘過期 
                Mark="NoCatch"        ’無Catch請(qǐng)求參數(shù)為 NoCatch 
                CFolder=GetCFolder        ’定義默認(rèn)的Catch文件保存目錄 
                CFile=Server.URLEncode(ScriptPath)&".txt"        ’將腳本路徑轉(zhuǎn)化為文件路徑 
                CatchData="" 
        end Sub 
        Private Function GetCFolder 
                dim FSO,CFolder 
                Set FSO=CreateObject("Scripting.FileSystemObject")        ’設(shè)置FSO對(duì)象 
                CFolder=Server.MapPath("/")&"/FileCatch/" 
                if not FSO.FolderExists(CFolder) then 
                        fso.CreateFolder(CFolder) 
                end if 
                if Month(Now())<10 then 
                        CFolder=CFolder&"/0"&Month(Now()) 
                else 
                        CFolder=CFolder&Month(Now()) 
                end if 
                if Day(Now())<10 then 
                        CFolder=CFolder&"0"&Day(Now())
 else 
                        CFolder=CFolder&Day(Now()) 
                end if 
                CFolder=CFolder&"/" 
                if not FSO.FolderExists(CFolder) then 
                        fso.CreateFolder(CFolder) 
                end if 
                GetCFolder=CFolder 
                set fso=nothing 
        End Function 
        Private Function bytes2BSTR(vIn)        ’轉(zhuǎn)換編碼的函數(shù) 
                dim StrReturn,ThisCharCode,i,NextCharCode 
                strReturn = "" 
                For i = 1 To LenB(vIn) 
                        ThisCharCode = AscB(MidB(vIn,i,1)) 
                        If ThisCharCode < &H80 Then 
                                strReturn = strReturn & Chr(ThisCharCode) 
                        Else 
                                NextCharCode = AscB(MidB(vIn,i+1,1)) 
                                strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
                                i = i + 1 
                        End If 
                Next 
                bytes2BSTR = strReturn 
        End Function 
        Public Function CatchNow(Rev)        ’用戶指定開始處理Catch操作 
                if UCase(request.Servervariables("Request_Method"))="POST" then 
                ’當(dāng)是POST方法,不可使用文件Catch 
                        Rev="使用POST方法請(qǐng)求頁面,不可以使用文件Catch功能" 
                        CatchNow=false 
                else 
                        if request.Querystring(Mark)<>"" then 
                        ’如果指定參數(shù)不為空,表示請(qǐng)求不可以使用Catch
 Rev="請(qǐng)求拒絕使用Catch功能" 
                                CatchNow=false 
                        else 
                                CatchNow=GetCatchData(Rev) 
                        end if 
                end if 
        End Function 
        Private Function GetCatchData(Rev)        ’讀取Catch數(shù)據(jù) 
                Dim FSO,IsBuildCatch 
                Set FSO=CreateObject("Scripting.FileSystemObject")        ’設(shè)置FSO對(duì)象,訪問CatchFile 
                If FSO.FileExists(CFolder&CFile) Then 
                        Dim File,LastCatch 
                        Set File=FSO.GetFile(CFolder&CFile)        ’定義CatchFile文件對(duì)象
                        LastCatch=CDate(File.DateLastModified) 
                        if DateDiff("n",LastCatch,Now())>Overdue then 
                        ’如果超過了Catch時(shí)間 
                                IsBuildCatch=true 
                        else 
                                IsBuildCatch=false 
                        end if 
                        Set File=Nothing 
                else 
                        IsBuildCatch=true 
                End if 
                If IsBuildCatch then 
                        GetCatchData=http://www.code-123.com/html/BuildCatch(Rev)        ’如果需要?jiǎng)?chuàng)建Catch,則創(chuàng)建Catch文件,同時(shí)設(shè)置Catch的數(shù)據(jù) 
                else 
                        GetCatchData=http://www.code-123.com/html/ReadCatch(Rev)        ’如果不需要?jiǎng)?chuàng)建Catch,則直接讀取Catch數(shù)據(jù) 
                End if 
                Set FSO=nothing
 End Function 
        Private Function GetScriptPath(IsGet)        ’創(chuàng)建一個(gè)包含所有請(qǐng)求數(shù)據(jù)的地址 
                dim Key,Fir 
                GetScriptPath=ScriptName 
                Fir=true 
                for Each key in Request.QueryString 
                        If Fir then 
                                GetScriptPath=GetScriptPath&"?" 
                                Fir=false 
                        else 
                                GetScriptPath=GetScriptPath&"&" 
                        end if 
                        GetScriptPath=GetScriptPath&Server.URLEncode(Key)&"="&Server.URLEncode(Request.QueryString(Key))
                Next 
                if IsGet then 
                        If Fir then 
                                GetScriptPath=GetScriptPath&"?" 
                                Fir=false 
                        else 
                                GetScriptPath=GetScriptPath&"&" 
                        end if 
                        GetScriptPath=GetScriptPath&Server.URLEncode(Mark)&"=yes" 
                end if 
        End Function 
        ’創(chuàng)建Catch文件 
        Private Function BuildCatch(Rev) 
                Dim HTTP,Url,OutCome 
                Set HTTP=CreateObject("Microsoft.XMLHTTP") 
’                On Error Resume Next 
’                response.write ServerHost&GetScriptPath(true) 
                HTTP.Open "get","http://"&ServerHost&GetScriptPath(true),False 
                HTTP.Send 
                if Err.number=0 then 
                        CatchData=http://www.code-123.com/html/bytes2BSTR(HTTP.responseBody)
    BuildCatch=True 
                else 
                        Rev="創(chuàng)建發(fā)生錯(cuò)誤:"&Err.Description 
                        BuildCatch=False 
                        Err.clear 
                end if 
                Call WriteCatch 
                set HTTP=nothing 
        End Function 
        Private Function ReadCatch(Rev) 
                ReadCatch=IReadCatch(CFolder&CFile,CatchData,Rev) 
        End Function 
        Private Sub WriteCatch 
                Dim FSO,TSO 
                Set FSO=CreateObject("Scripting.FileSystemObject")        ’設(shè)置FSO對(duì)象,訪問CatchFile 
                set TSO=FSO.CreateTextFile(CFolder&CFile,true) 
                TSO.Write(CatchData) 
                Set TSO=Nothing 
                Set FSO=Nothing 
        End Sub 
End Class 
Function IReadCatch(File,Data,Rev) 
        Dim FSO,TSO 
        Set FSO=CreateObject("Scripting.FileSystemObject")        ’設(shè)置FSO對(duì)象,訪問CatchFile 
’        on error resume next 
        set TSO=FSO.OpenTextFile(File,1,false) 
        Data=http://www.code-123.com/html/TSO.ReadAll 
        if Err.number<>0 then 
                Rev="讀取發(fā)生錯(cuò)誤:"&Err.Description 
                ReadCatch=False 
                Err.clear 
        else 
                IReadCatch=True 
        end if 
        Set TSO=Nothing 
        Set FSO=Nothing 
End Function 
%>

分享:asp調(diào)用c#編制的com組件實(shí)例
1新建類庫MyTestDLL 2右擊項(xiàng)目MyTestDLL-》屬性-》生成-》勾選為COM互操作注冊 3打開AssemblyInfo.cs文件修改[assembly:ComVisible(true)] 4打開VisualSutdio2008的命令提示行工具輸入guidgen.exe選擇DEFINE_GUID單擊NewGUID 5代碼 1、每個(gè)類名對(duì)應(yīng)一個(gè)接口名,接口名

來源:模板無憂//所屬分類:ASP教程/更新時(shí)間:2013-04-24
相關(guān)ASP教程