Recomendado: ASP evita que las páginas web sean refrescantes Reduce the server burden, asp prevents web page refresh code SubPreventRefresh() DimRefreshTime, isRefreshRefreshTime=10 prevents refresh time, unit (seconds) isRefresh=1 Whether to use anti-refresh function, 0=No, 1=YesIfisRefresh=1Then If(NotIsEmpty(Session(RefreshTime)))AndRefreshTime0Then IfDateDiff(s,Se
Cómo usarlo, agregue el siguiente código a la página donde necesita usar el caché de archivos.
<!-#includeFile = fileCatch.asp->
<%
SetMyCatch = NewCatchFile
Mycatch.overdue = 10 'Modificar el tiempo de vencimiento establecido en 10 minutos
ifmycatch.catchnow (rev) entonces
Response.WriteMyCatch.CatchData
respuesta.
endif
setmycatch = nada
%>
FileCatch.asp
Copiar contenido al código de portapletro:
<%
'Este archivo se usa para verificar el archivo original e implementar la captura del archivo de la página
'1. Si la solicitud de archivo es el modo de publicación, cancele esta función
'2. Las solicitudes de archivo no pueden contener palabras clave de identificación del sistema
ClassCatchFile
Publicación, Mark, Colder, Cfile 'Definir los parámetros del sistema
PrivatescriptName, scriptPath, serverhost 'definir variables de parámetros de servidor/página
Datos de salida de PublicCatchData
PrivateUbclass_initialize 'Inicializar la función
'Obtener datos de servidor y script
ScriptName = request.ServerVariAbles (script_name) 'Reconocer la dirección virtual del script actual
ScriptPath = getScriptPath (falso) 'Identifique la dirección GET completa del script
Serverhost = request.ServerVariAbles (server_name) 'Identifique la dirección del servidor actual
'Inicializar los parámetros del sistema
Vencido = 30 'caduca 30 minutos vence
Mark = noCatch 'No hay parámetro de solicitud de captura es nocatch
Cfeder = getcfolder 'Defina el directorio de guardar archivo de captura predeterminado
Cfile = server.urlencode (scriptPath) &. Txt 'Convertir la ruta de script a la ruta de archivo
CatchData =
Endsub
Privatefunctiongetcfolder
dimfso, cfolder
Setfso = createObject (scripting.filesystemObject) 'Establecer el objeto FSO
Colder = server.mappath (/) &/fileCatch/
ifnotfso.foldereRexists (cfolder) entonces
FSO.CreateFolder (Colder)
endif
ifmonth (ahora ()) <10
Colder = cfolder &/0 & mes (ahora ())
demás
Colder = cfolder & mes (ahora ())
endif
ifday (ahora ()) <10
Colder = cfolder & 0 & Day (ahora ())
Colder = cfolder & Day (ahora ())
endif
Colder = cfolder &//
ifnotfso.foldereRexists (cfolder) entonces
FSO.CreateFolder (Colder)
endif
Getcfolder = cfolder
setfso = nada
Función final
PrivateFunctionBytes2BStr (VIN) 'Convertir Función codificada
dimstrreturn, thischarcode, i, nextcharcode
strreturn =
Fori = 1TolenB (vin)
ThisCharCode = ASCB (MidB (Vin, I, 1))
Ifthischarcode <& h80Then
strreturn = strreturn & chr (thisCharcode)
Demás
Nextcharcode = ascb (midb (vin, i+1,1))
strreturn = strreturn & chr (clng (thisCharCode)*& H100+cint (nextcharcode)))
i = i+1
Endif
Próximo
bytes2bstr = strreturn
Función final
PublicFunctionCatchnow (Rev) 'El usuario especifica para comenzar a procesar la operación de captura
ifucase (request.servervariables (request_method)) = postthen
'Si se trata de un método de publicación, la captura de archivos no se puede usar
Rev = Página de solicitud Usando el método de publicación, la función de captura de archivo no se puede usar
CatchNow = falso
demás
ifrequest.querystring (Mark) <> entonces
'Si el parámetro especificado no está vacío, significa que la solicitud no puede usar captura
CatchNow = falso
demás
CatchNow = GetCatchData (Rev)
endif
endif
Función final
PrivateFunctiongetCatchData (Rev) 'Leer Datos de captura
Dimfso, isbuildcatch
SetFSO = createObject (scripting.filesystemObject) 'Establezca el objeto FSO y acceda a CatchFile
Iffso.fileExists (colder & cfile) entonces
Dimfile, LastCatch
SetFile = fso.getfile (cfolder & cfile) 'Defina el objeto de archivo de CatchFile
LastCatch = CDATE (File.DatelastModified)
ifdatediff (n, lastCatch, ahora ())> sobredu
'Si se excede el tiempo de captura
IsBuildCatch = True
demás
IsBuildCatch = falso
endif
Setfile = nada
demás
IsBuildCatch = True
Endif
IfisbuildCatchthen
GetCatchData = http: //www.code-123.com/html/buildcatch (rev) 'Si necesita crear una captura, crear un archivo de captura y establecer los datos de captura al mismo tiempo
demás
GetCatchData = http: //www.code-123.com/html/readcatch (rev) 'Si no necesita crear una captura, lea los datos de captura directamente
Endif
Setfso = nada
PrivateFunctionGetScriptPath (ISGET) 'Crear una dirección que contenga todos los datos solicitados
dimkey, abeto
GetScriptPath = scriptName
Fir = verdadero
foreachkeyinRequest.Querystring
Sifirthen
GetScriptPath = getScriptPath &?
Fir = falso
demás
GetScriptPath = getScriptPath &&
endif
GetScriptPath = getScriptPath & Server.urlencode (Key) & = & server.urlencode (request.QueryString (Key))
Próximo
ifisgetthen
Sifirthen
GetScriptPath = getScriptPath &?
Fir = falso
demás
GetScriptPath = getScriptPath &&
endif
GetScriptPath = getScriptPath & Server.urlencode (Mark) & = sí
endif
Función final
'Crea un archivo de captura
PrivateFunctionBuildCatch (Rev)
Dimhttp, url, resultado
Sethttp = createObject (microsoft.xmlhttp)
'OnerrorResumEnext
'Response.WriteserverHost & getcriptpath (verdadero)
Http.openget, http: // & serverhost & getScriptPath (verdadero), falso
Http.send
iferr.number = 0then
CatchData = http: //www.code-123.com/html/bytes2bstr (http.ResponseBody)
demás
Rev = error ocurrido en la creación: & err.description
BuildCatch = falso
Err.Clear
endif
CallwriteCatch
sethttp = nada
Función final
PrivateFunctionReadCatch (Rev)
ReadCatch = IreadCatch (Colder & Cfile, CatchData, Rev)
Función final
PrivateSubWriteCatch
Dimfso, tso
SetFSO = createObject (scripting.filesystemObject) 'Establezca el objeto FSO y acceda a CatchFile
settso = fso.createTextFile (cfolder & cfile, verdadero)
Tso.write (chatchdata)
Settso = nada
Setfso = nada
Endsub
Clase final
FunctionIreadCatch (archivo, datos, rev)
Dimfso, tso
SetFSO = createObject (scripting.filesystemObject) 'Establezca el objeto FSO y acceda a CatchFile
'OnerrorResumEnext
settso = fso.opentextfile (archivo, 1, falso)
Data = http: //www.code-123.com/html/tso.readall
iferr.number <> 0then
Rev = Error ocurrió en la lectura: & Err.Description
ReadCatch = falso
Err.Clear
demás
IReadCatch = True
endif
Settso = nada
Setfso = nada
Función final
%>
Compartir: ASP Calls C# Ejemplo de componente Com compilado 1 Create a new class library MyTestDLL 2 Right-click the project MyTestDLL-》Attribute-》Generate-》Tick as COM Interoperability Registration 3 Open AssemblyInfo.cs file modification [assembly:ComVisible(true)] 4 Open the command prompt line tool for VisualSutdio2008 Enter DEFINE_GUID Click NewGUID 5 Code 1. Each class name corresponds to an interface name, interface name