T?o Custom ASP l?i trang

D?ch tiu ? D?ch tiu ?
ID c?a bi: 224070
Bung t?t c? | Thu g?n t?t c?

TM T?T

Phin b?n Microsoft Internet Information Services (IIS) 5.0 gi?i thi?u kh? nng t?o ty ch?nh cc trang l?i Active Server Pages (ASP) thng qua vi?c b? sung m?t phng php m?i ? built-in ASP Server ?i t?ng ?c g?i l Server.GetLastError() m tr? v? m?t m?i ASPError ?i t?ng.

THNG TIN THM

Khi m?t l?i x?y ra trong khi b?n bin d?ch ho?c ch?y m?t trang ASP, IIS t?o ra m?t l?i 500; 100 v th?c hi?n m?t phng php Server.Transfer() ? v?t qua ki?m sot ? trang l?i ty ch?nh hi?n ang ?c xc ?nh. (Theo m?c ?nh Trang ny l /iishelp/common/500-100.asp) ? bi?t thm chi ti?t v? phng php Server.Transfer(), xem bi vi?t sau trong c s? ki?n th?c Microsoft:
219294 Lm th? no ? s? d?ng phng php Server.Transfer
Khi ki?m sot ?c thng qua ? trang l?i ty ch?nh, cc phng php Server.GetLastError() c th? ?c s? d?ng ? c ?c thng tin chi ti?t v? l?i x?y ra. Phng php Server.GetLastError() tr? v? m?t ?i t?ng ASPError ? thu?c tnh ?c li?t k trong b?ng sau. (B?ng ny c?ng c th? ?c t?m th?y trong ti li?u h?ng d?n tr?c tuy?n IIS 5.0.)
Thu g?n b?ng nyBung r?ng b?ng ny
B?t ?ng s?nM ta
ASPCodeTr? v? m?t m? l?i ?c t?o ra b?i IIS.
S?Tr? v? m? l?i COM tiu chu?n.
Ngu?nCho bi?t n?u l ngu?n g?c c?a l?i ? ?c n?i b? ? ASP, ngn ng? k?ch b?n ho?c m?t ?i t?ng.
TpCh? ra tn t?p .asp ? ?c x? l? khi x?y ra l?i.
D?ngCh? ra ?ng trong file .asp t?o l?i.
M taTr? v? m?t m t? ng?n v? l?i.
ASPDescriptionTr? v? m?t m t? chi ti?t hn v? l?i n?u l m?t l?i lin quan ?n ASP.
Cc b?c ?c li?t k d?i y s? h?ng d?n b?n thng qua vi?c thi?t l?p m?t trang l?i ty ch?nh ASP.
  1. Lu ASP m? sau y trong th m?c t?p l?nh nh "My500.asp" (khng c d?u ngo?c kp):
    <%@Language="VBSCRIPT"%>
    <%
      Option Explicit
      On Error Resume Next
      Response.Clear
      Dim objError
      Set objError = Server.GetLastError()
    %>
    <html>
    <head>
    <title>ASP 500 Error</title>
    <style>
    BODY  { FONT-FAMILY: Arial; FONT-SIZE: 10pt;
            BACKGROUND: #ffffff; COLOR: #000000;
            MARGIN: 15px; }
    H2    { FONT-SIZE: 16pt; COLOR: #ff0000; }
    TABLE { BACKGROUND: #000000; PADDING: 5px; }
    TH    { BACKGROUND: #0000ff; COLOR: #ffffff; }
    TR    { BACKGROUND: #cccccc; COLOR: #000000; }
    </style>
    </head>
    <body>
    
    <h2 align="center">ASP 500 Error</h2>
    
    <p align="center">An error occurred processing the page you requested.<br>
    Please see the details below for more information.</p>
    
    <div align="center"><center>
    
    <table>
    <% If Len(CStr(objError.ASPCode)) > 0 Then %>
      <tr>
        <th nowrap align="left" valign="top">IIS Error Number</th>
        <td align="left" valign="top"><%=objError.ASPCode%></td>
      </tr>
    <% End If %>
    <% If Len(CStr(objError.Number)) > 0 Then %>
      <tr>
        <th nowrap align="left" valign="top">COM Error Number</th>
        <td align="left" valign="top"><%=objError.Number%>
        <%=" (0x" & Hex(objError.Number) & ")"%></td>
      </tr>
    <% End If %>
    <% If Len(CStr(objError.Source)) > 0 Then %>
      <tr>
        <th nowrap align="left" valign="top">Error Source</th>
        <td align="left" valign="top"><%=objError.Source%></td>
      </tr>
    <% End If %>
    <% If Len(CStr(objError.File)) > 0 Then %>
      <tr>
        <th nowrap align="left" valign="top">File Name</th>
        <td align="left" valign="top"><%=objError.File%></td>
      </tr>
    <% End If %>
    <% If Len(CStr(objError.Line)) > 0 Then %>
      <tr>
        <th nowrap align="left" valign="top">Line Number</th>
        <td align="left" valign="top"><%=objError.Line%></td>
      </tr>
    <% End If %>
    <% If Len(CStr(objError.Description)) > 0 Then %>
      <tr>
        <th nowrap align="left" valign="top">Brief Description</th>
        <td align="left" valign="top"><%=objError.Description%></td>
      </tr>
    <% End If %>
    <% If Len(CStr(objError.ASPDescription)) > 0 Then %>
      <tr>
        <th nowrap align="left" valign="top">Full Description</th>
        <td align="left" valign="top"><%=objError.ASPDescription%></td>
      </tr>
    <% End If %>
    </table>
    
    </center></div>
    
    </body>
    </html>
    						
  2. Thi?t l?p ty ch?nh ASP l?i trang:

    1. M? tr?nh qu?n l? d?ch v? Internet trong MMC.
    2. M? r?ng c?a b?n trang Web.
    3. Nh?p chu?t ph?i vo th m?c script v ch?n Thu?c tnh.
    4. B?m vo cc Ty ch?nh l?i tab.
    5. Di chuy?n xu?ng v lm n?i b?t l?i HTTP 500; 100 v nh?p vo S?a thu?c tnh.
    6. ?m b?o r?ng Lo?i tin nh?n ?c thi?t l?p ? URL.
    7. Thay ?i cc URL ? "/ scripts/my500.asp" (khng c d?u ngo?c kp).
    8. Nh?p vo Ok cho ?n khi b?n tr? v? MMC.
  3. Ki?m tra l?i trang web m?i:

    1. Lu t?t c? cc trang sau y trong th m?c t?p l?nh:

      • Ti?t ki?m trang sau y l "Badpage1.asp" (khng c d?u ngo?c kp):
        <%@Language="VBSCRIPT"%>
        <html>
        <head>
        <title>Bad Page 1</title>
        </head>
        <body>
        <% Response.Write 1/0 %>
        </body>
        </html>
        										
      • Ti?t ki?m trang sau y l Badpage2.asp"(khng c d?u ngo?c kp):
        <%@Language="VBSCRIPT"%>
        <html>
        <head>
        <title>Bad Page 2</title>
        </head>
        <body>
        <% Response.BadMethod "Hello" %>
        </body>
        </html>
        										
      • Ti?t ki?m trang sau y l "Badpage3.asp" (khng c d?u ngo?c kp):
        <%@Language="VBSCRIPT"%>
        <html>
        <head>
        <title>Bad Page 3</title>
        </head>
        <body>
        <%
          Dim objBad
          Set objBad = Server.CreateObject("BAD.OBJECT.CLASS")
        %>
        </body>
        </html>
        										
    2. Khi b?n duy?t b?t k? c?a cc trang ? trn, b?n s? th?y trang ty ch?nh l?i quay tr? l?i tr?nh duy?t.
CHU Y: Khi s? d?ng Internet Explorer 5.0 v sau ? xem cc trang l?i ty ch?nh ASP, k?t qu? b?t ng? c th? ?c tr? l?i. IE5 gi?i thi?u m?t tnh nng ? thay th? cc m?u HTML cho HTTP 500, v m?t s? khc th?ng tr? v? m? tr?ng thi, v?i nh?ng thng i?p tiu chu?n ha, phi c? th?. ? b? qua tnh nng ny v hi?n th? vn b?n chnh xc c?a m? tr?ng thi quay tr? v? tr?nh duy?t, m? Internet Explorer v i?u h?ng ?n:
Tools | Internet Options | Advanced
					

sau b? ch?n h?p ki?m c nh?n
Show friendly HTTP error messages
					

Thm thng tin v? tnh nng ny c s?n trong
218155 M t? c?a thng bo l?i giao th?c siu vn b?n giao thng v?n t?i

Thu?c tnh

ID c?a bi: 224070 - L?n xem xt sau cng: 21 Thang Tam 2011 - Xem xt l?i: 2.0
T? kha:
kbaspobj kbcodesnippet kbinfo kbmt KB224070 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:224070
Khc t Ni dung trong C s Kin thc Khng con c h tr
Bi vi?t ny ni v? cc s?n ph?m m Microsoft khng c?n h? tr? n?a. Do , bi vi?t ny ?c cung c?p "nguyn b?n" v s? khng ?c c?p nh?t.

Cung cp Phan hi

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com