Website does not work when moving the files to another server?

非 Y 不嫁゛ 提交于 2019-12-25 18:56:11

问题


![enter image description here][1]I'm trying to troubleshoot this problem. I created a basic asp page with Javascript in one server which works fine at the moment but when I move the asp page and all the related files to the new server it does not work. What my asp page does is ask for last or first name in text box and it has button which after it is press it returns all the matches with contact info. from Microsoft Access database.

HTML :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!-- JQuery Library used so that phone_dir.js can use JQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>

    <title>Corporate Phone Directory</title>
    </head>

    <body bgcolor="#FFFFFF" link="#003399">
     <br>
     <br>
     <div style="font-size: 16px; font-family: Arial; color:#D6D6D6;"> 
      <table width="745" height="81" border="0" align="left" bordercolor="#003399">
      <tr>
    <td width="300" height="50" align="left" valign="top">
    <div align="left" valign="bottom">
    Search by either First or Last Name: 
    <br>
    <br>   
          <input name="Search" type="text" id="Search" value="">
          <input name="btnFind2" type="button" id="btnFind2" value="Find"   onClick="searchphonedirectory()">

    </div>
       </table>
      </div>
      <br>
       <br>
       <br>
       <br>
       <br>
       <br>
       <br>
        <hr>
        <div style="font-size: 16px; font-family: Arial; color:#D6D6D6;"  align="left"   id='results'>
       <!-- Your results will go here -->
       </div>


     </body>
     </html>

Javascript :

$(document).ready(function()
     {

    $( "#Search" ).keypress(function() 
       {
        if(event.keyCode==13) 
        {
            $("#btnFind2").click();
        }; // End of If key code = Enter function
    }); 

 });

 function searchphonedirectory()
 {  
    var searchentry = document.getElementById('search').value;

    if (window.XMLHttpRequest)
    {
        xmlhttp2=new XMLHttpRequest();
    }
    else
    {
        xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp2.onreadystatechange=function()
    {
      if (xmlhttp2.readyState==4)
       {
        document.getElementById("results").innerHTML =   xmlhttp2.responseText;
       }

     }
     xmlhttp2.open("GET","phoneResults.asp?searchentry="+searchentry,true);
     xmlhttp2.send();

 };

Other Code which generates the results.

 <!--#include file="ASPFiles/phoneDirectory.asp" -->
      <%

          response.expires=-1

      err.clear

     on error resume next
 '*----------------------------------------------------------------
   searchentry = request.querystring("searchentry")
 '*----------------------------------------------------------------


     sql = "SELECT PhoneDirectory.Name, PhoneDirectory.[Phone#], PhoneDirectory.OfficeExtension, 
     PhoneDirectory.[Mobile#] "
     sql = sql +"FROM PhoneDirectory "
     sql = sql +"WHERE (PhoneDirectory.LastName Like '" & searchentry & "%' OR     
     PhoneDirectory.FirstName Like '" & searchentry & "%' ) "
     sql =  sql + "ORDER BY LASTNAME,FIRSTNAME"

     set rs=Server.CreateObject("ADODB.Recordset")
     rs.Open sql,conn

      'response.write(sql)
       response.write("<table>")
       response.write("<td width='22%' align='left' height='29'>Name</th>")
       response.write("<td width='11%' align='left' >Phone</th>")
       response.write("<td width='1%' align='left' >Ext</th>")
       response.write("<td width='12%' align='left' >Mobile</th>")
       response.write("</tr>")




  do until rs.EOF   



response.write("<tr>")

for each x in rs.Fields

    response.write("<td align='left' >" & x.value & "</td>")

next

rs.MoveNext

response.write("</tr>")

      loop

       response.write("</table>")
     %>    

This one opens the database:

    <%
' FileName="Connection_odbc_conn_dsn.htm"
' Type="ADO" 
' DesigntimeType="ADO"
' HTTP="true"
' Catalog=""
' Schema=""
'Dim MM_phoneDirectory_STRING
'MM_phoneDirectory_STRING = "dsn=PhoneDB;"


 set conn=Server.CreateObject("ADODB.Connection")
 conn.Provider="Microsoft.Jet.OLEDB.4.0"

'TESTING DB
 conn.Open(Server.Mappath("/webs/corporatenet2/databases/Phone_Directory.mdb"))


  %>

回答1:


First thing is you missed to mention the event" in keypress event and remove the searchphonedirectory() function from HTML input "onClick",

 <input name="btnFind2" type="button" id="btnFind2" value="Find">

Add it to your javascript code like this.

 $( "#Search" ).keypress(function(event) 
 {
    if(event.keyCode==13) 
    {
       searchphonedirectory();
    }; // End of If key code = Enter function
}); //End of Search Keypress Function

hope it helps.




回答2:


This may not be an answer, but it will certainly help you in the right direction, if the problem is ASP based.

On the root of your web server (\inetpub\wwwroot), create a folder called errors. In that folder create a file called error.asp and paste the following into it...

<%Option Explicit%>
<%
    dim LOGON_USER
    LOGON_USER = UCASE(Request.ServerVariables ("LOGON_USER"))
    PATH = request.ServerVariables("PATH_TRANSLATED")
    Const lngMaxFormBytes = 2000
    Dim objASPError, blnErrorWritten, strServername, strServerIP, strRemoteIP
    Dim strMethod, lngPos, datNow, strQueryString, strURL,PATH
    Dim arrError,i
    If  Response.Buffer Then
        Response.Clear
        Response.Status = "500 Internal Server Error"
        Response.ContentType = "text/html"
        Response.Expires = 0
    End If

    Set objASPError = Server.GetLastError

%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<html>

    <head>

        <title>eDischarge encountered an error...</title>
        <meta http-equiv="Content-Type" content="text-html; charset=Windows-1252">
        <link href="includes\stylesheet.css" rel="stylesheet" type="text/css">
        <style type="text/css">
            <!--
                html {
                    font-family: Arial, Helvetica, sans-serif;
                }
                html body {
                    font-family: Arial, Helvetica, sans-serif;
                }
                body {
                    font-family: Arial, Helvetica, sans-serif;
                    color: #330000;
                    margin: 0;
                    padding: 0;
                }
                p {
                    font-size: 90%;
                }
                .errortitle {
                    font-family: Arial, Helvetica, sans-serif;
                    color: white;
                    font-size: 150%;
                    font-weight: bold;
                    width: 100%;
                    background-color: #770000;
                    padding: 1em;
                }
                .errorbody {
                    padding: 2em;
                    background: url(http://stas35/errors/images/error.gif) no-repeat top left;
                }
                .errormessage {
                    border-left: 10px solid #770000;
                    padding: 0 0 0 1em;
                    margin-left: 2em;
                    color: #770000;
                }
                .errorpadleft {
                    padding-left: 2em;
                }
            -->
        </style>

    </head>

    <%
        strError = strError & "<p><strong>Error Type:</strong></p>"
        strError = strError & "<p class=""errorpadleft"">" & Server.HTMLEncode(objASPError.Category) & "</p>"
        If objASPError.ASPCode > "" Then 
            strError = strError & "<p class=""errorpadleft"">" & Server.HTMLEncode(", " & objASPError.ASPCode) & "</p>"
        end if

        strError = strError & "<p class=""errorpadleft"">" & Server.HTMLEncode(" (0x" & Hex(objASPError.Number) & ")" )  & "</p>"
        If objASPError.ASPDescription > "" Then 
            strError = strError & Server.HTMLEncode(objASPError.ASPDescription) & "<br/>"
        elseIF (objASPError.Description > "") Then 
            strError = strError & "<p class=""errorpadleft"">" &  Server.HTMLEncode(objASPError.Description)  & "</p>"
        end if

        blnErrorWritten = False

          ' Only show the Source if it is available and the request is from the same machine as IIS
        If objASPError.Source > "" Then
            strServername = LCase(Request.ServerVariables("SERVER_NAME"))
            strServerIP   = Request.ServerVariables("LOCAL_ADDR")
            strRemoteIP   = Request.ServerVariables("REMOTE_ADDR")
            If (strServername = "localhost" Or strServerIP = strRemoteIP) And objASPError.File <> "?" Then
                strError = strError & "<p class=""errorpadleft"">" & Server.HTMLEncode(objASPError.File)
                If objASPError.Line > 0 Then 
                    strError = strError & ", line " & objASPError.Line
                end if
                If objASPError.Column > 0 Then 
                    strError = strError & ", column " & objASPError.Column
                end if
                strError = strError & "</p>"
                strError = strError & "<p class=""errorpadleft"">" & Server.HTMLEncode(objASPError.Source) & "</p>"
                If objASPError.Column > 0 Then  strError = strError & "<p class=""errorpadleft"">" & String((objASPError.Column - 1), "-") & "</p>"
                blnErrorWritten = True
            End If
        End If

        If Not blnErrorWritten And objASPError.File <> "?" Then
            strError =strError & "<p class=""errorpadleft"">" & Server.HTMLEncode(  objASPError.File)
            If objASPError.Line > 0 Then 
                strError =strError & Server.HTMLEncode(", line " & objASPError.Line)
            end if
            If objASPError.Column > 0 Then
                strError =strError & ", column " & objASPError.Column
            end if
            strError = strError & "</p>"
          End If

        strError = strError & "<p><strong>Browser Type:</strong></p>"
        strError = strError & "<p class=""errorpadleft"">" & Server.HTMLEncode(Request.ServerVariables("HTTP_USER_AGENT")) & "</p>"

        strMethod = Request.ServerVariables("REQUEST_METHOD")
        If strMethod = "POST" Then
            strError =strError & "<p class=""errorpadleft"">POST Data: (" & Request.TotalBytes & " bytes "
            If lngPos > 1 Then strError =strError & "?" & Server.HTMLEncode(Left(Request.QueryString, (lngPos - 1)))
            strError =strError & ")</p>"
            arrError = split(Request.Form,"&")
            For i = LBound(arrError) To UBound(arrError)
                strError =strError & "<p>"  & Server.HTMLEncode(arrError(i)) & "</p>"
            Next
        End If

        strError = strError & _
            "<p>" & _
                "<strong>User Logon: </strong>" & LOGON_USER & "<br/>" & _
                "<strong>User IP: </strong>" & Request.ServerVariables ("REMOTE_ADDR") & "<strong><br/>" & _
                "Time: </strong>" & Now() & _
            "</p>"
        SendMail email_from,email_to,system_name &" 500-100 Error  " & LOGON_USER,"<HTML>" & PATH & "<BR><BR>" & replace(strError,"%2F","/") & "</HTML>" ,2
    %>

    <body>
        <div class="errortitle">Your system has encountered an error...</div>
        <div class="errorbody">
            <div class="errormessage"><%=strError%></div>
        </div>
    </body>

</html>

Now, in IIS, navigate to the Custom Erros section and scroll down to the 500 error. Edit... this error and select URL as the Message Type. In the URL box, beneath, type /errors/error.asp (remember that the folder should be on the root of your web server [this is usually <drive>\Inetpub\wwwroot] - if you choose to put it elsewhere then this won't work until you resolve the path).

Now try running your pages again and see if you get any ASP error messages. Your page should be redirected to the error.asp page if there is an error.

(Let me know if there are any errors with the code above - I had to mod it on the fly and haven't had chance to test it).



来源:https://stackoverflow.com/questions/24421660/website-does-not-work-when-moving-the-files-to-another-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!