将文件移动到另一台服务器时,网站无法正常工作?

时间:2014-06-26 02:53:41

标签: javascript asp-classic windows-server-2008-r2

![在此处输入图片说明] [1]我正在尝试解决此问题。我在一台服务器上创建了一个基本的asp页面,其中包含 Javascript ,目前工作正常但是当我将 asp页面和所有相关文件移动到新服务器时它没有工作。我的asp页面的作用是在文本框中询问姓氏或名字,它有按钮,按下它后返回所有匹配联系信息。来自 Microsoft Access数据库

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();

 };

生成结果的其他代码。

 <!--#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>")
     %>    

这个打开数据库:

    <%
' 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"))


  %>

2 个答案:

答案 0 :(得分:0)

首先,你错过了在按键事件中提及事件并从HTML输入中删除了searchphonedirectory()函数“onClick”,

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

将它添加到您的javascript代码中。

 $( "#Search" ).keypress(function(event) 
 {
    if(event.keyCode==13) 
    {
       searchphonedirectory();
    }; // End of If key code = Enter function
}); //End of Search Keypress Function
希望它有所帮助。

答案 1 :(得分:0)

这可能不是一个答案,但如果问题是基于ASP,它肯定会帮助你朝着正确的方向前进。

在网络服务器(\ inetpub \ wwwroot)的根目录下,创建一个名为错误的文件夹。在该文件夹中创建一个名为 error.asp 的文件,并将以下内容粘贴到其中...

<%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>

现在,在IIS中,导航到自定义错误部分,然后向下滚动到 500 错误。 修改... 此错误,然后选择网址作为消息类型。在网址框中,在下方输入/errors/error.asp(请记住该文件夹应位于您的网络服务器的 [通常为<drive>\Inetpub\wwwroot ] - 如果你选择将它放在其他地方,那么在你解决这条路径之前,这将无法工作。)

现在再次尝试运行您的页面,看看是否收到任何ASP错误消息。如果出现错误,您的页面重定向到error.asp页面。

(如果上面的代码有任何错误,请告诉我 - 我必须动态修改它并且没有机会测试它。)