首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

关于URL的相对路径跟绝对路径.知道的请进来

2013-09-09 
关于URL的相对路径和绝对路径.知道的请进来.URL红色部分问题. 如何设置相对路径?知道的请告知一下,万分感

关于URL的相对路径和绝对路径.知道的请进来.
URL红色部分问题. 如何设置相对路径?知道的请告知一下,万分感谢

Dim time2,time1
time1=timer

Url = "http://www.baidu.com/index2.asp"
Url = "index2.asp"

cacheTime=600   '缓存时间,单位为s秒

'强制生成!
If Request.QueryString("g")<>"" Then Call makecache()

'判断 自动生成!
If application("ourcyindex")<>"" And isDate(application("tqexpire_ourcyindex")) Then '如果缓存的日期存在并且符合时间日期格式
    If CDate(application("tqexpire_ourcyindex"))<Now()  Then makecache() '如果缓存到期时间小于了现在的时间,就是过期了,调用生成缓存过程。
Else
    makecache()'如果缓存日期不存在或者不符合时间日期格式,直接调用生成过程。
End If

time2=timer
'这是我为了去掉我站内的执行时间而进行的替换,你可以不管,直接输出application("ourcyindex")就行了

response.write Replace(application("ourcyindex"),"info@ourcy.com","info@ourcy.com 执行时间 "& FormatNumber((time2-time1)*1000,1) &" 毫秒 缓存过期:"& application("tqexpire_ourcyindex")&"")


'定义生成缓存过程
Sub makecache
    List_PageCode=getHTTPPage(Url)
    application.lock
    application("ourcyindex")=List_PageCode
    application("tqexpire_ourcyindex")=dateadd("s",cacheTime,Now()) 
    application.unlock
End Sub




Function getHTTPPage(url) 
    IF(IsObjInstalled("Microsoft.XMLHTTP") = False)THEN
        Response.Write "<br><br>服务器不支持Microsoft.XMLHTTP组件" 
        Err.Clear
        Response.End
    END IF
    On Error Resume Next
    Dim http 
    SET http=Server.CreateObject("Msxml2.XMLHTTP") 
    Http.open "GET",url,False 
    Http.send() 
    IF(Http.readystate<>4)THEN
        Exit Function 
    END IF 
    getHTTPPage=BytesToBSTR(Http.responseBody,"GB2312")
    SET http=NOTHING
    IF(Err.number<>0)THEN
        Response.Write "<br><br>获取文件内容出错" 
        'Response.End
        Err.Clear
    END IF  
End Function



        
Function BytesToBstr(CodeBody,CodeSet)
    Dim objStream
    SET objStream = Server.CreateObject("adodb.stream")
    objStream.Type = 1
    objStream.Mode =3
    objStream.Open
    objStream.Write CodeBody
    objStream.Position = 0
    objStream.Type = 2
    objStream.Charset = CodeSet
    BytesToBstr = objStream.ReadText 
    objStream.Close
    SET objStream = NOTHING
End Function

'================================================
'作  用:检查组件是否已经安装
'返回值:True  ----已经安装
'        False ----没有安装
'================================================
Function IsObjInstalled(objName)
    On Error Resume Next
    IsObjInstalled = False
    Err = 0
    Dim testObj
    SET testObj = Server.CreateObject(objName)
    IF(0 = Err)THEN IsObjInstalled = True
    SET testObj = NOTHING
    Err = 0
End Function


Function cleanTime(str)
Dim re
Set re=new regExp
re.pattern="(\执行时间)(.*?)(\毫秒)"
re.IgnoreCase =false
re.Global=True
str=re.Replace(str,"")
cleanTime=str
End Function
[解决办法]
XMLHTTP 只能用绝对路径

 Sub makecache
   if inStr(Path,"://")=0 then
    Path="http://" & Request.ServerVariables("server_name") & Request.ServerVariables("HTTP_url")
    Pos=InStrRev(Path,"/")
    Url=left(path,Pos)&Url
    end if
    List_PageCode=getHTTPPage(Url)
    .................

热点排行