Results 1 to 2 of 2

Thread: The Page Cannot Be Found

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    South Africa
    Posts
    113

    The Page Cannot Be Found

    Hi,
    I have a project where I read from a SQL database fields for a qualification. One of the fields is "document path". If this field is not null, i then try and retrieve the actual document. If the document path is null, i just display the fields in typical asp fashion.

    My problem is that sometimes the document path field has data, but the physical document actually isnt there, and so, the browser displays a url that does not exist and I get the "Page cannot be displayed".

    I need to be able to have code that says...if the document isnt there, then treat it the same way it handles the scenario when the document path is null.

    Code:
    if len(trim(rslist("DocumentPath"))) > 0 then
       url="../../US/Documents/" & rslist("DocumentPath")
       Response.Redirect(url)
    					
    else
    					
    display all fields...
    %>
    any advice is welcome..
    thankls in advance
    You are living a pacifist dream, and if you dreaming it means you sleeping and you should damn well wake up!

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    You should check to see if the file exists before displaying it.

    VB Code:
    1. Dim FileName
    2.  
    3. FileName = "MyFile.asp"
    4. FileName = Server.MapPath("/Files/" & FileName)
    5.  
    6. If IsFileExists(FileName) = True  Then
    7.  Response.Write "File exists"
    8. Else
    9.  Response.Write "File does not exists"
    10. End If
    11.  
    12.  
    13. ' **********************************
    14. ' Function to check file Existance
    15. ' **********************************
    16. Function IsFileExists(byVal FileName)
    17.  
    18.  If FileName = ""  Then
    19.   IsFileExists = False
    20.   Exit Function
    21.  End If
    22.  
    23.  Dim objFSO
    24.    
    25.  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    26.    
    27.  If (objFSO.FileExists( FileName ) = True  Then
    28.   IsFileExists = True
    29.  Else
    30.   IsFileExists = False
    31.  End If
    32.  
    33.  Set objFSO = Nothing  
    34. End Function

    (Sample code, modify it!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width