Sideway
output.to from Sideway





Draft for Information Only

Content

Response Object
Response.Status Property
   Syntax:
   Parameters:
   Remarks:
   Examples:
Response.Redirect Method
   Syntax:
   Parameters:
   Return Values:
   Remarks:
   Examples:

Response Object

Another important function of Response object is the output of HTTP status to the client. As part of the HTTP header, these types of response objects should be sent before sending any body content to the client.

Response.Status Property

Response.Status property sets the value of the status line of HTTP response before the HTTP headers returned by the server to the client.

Syntax:

Response.Status =[StatusDescription]

 Or in an ASP file. Imply

<% Response.Status=[StatusDescription] %>

Parameters:

StatusDescription

The parameter "StatusDescription" is the status code with a brief description. The data type of "StatusDescription" is string and is enclosed by quotation marks (" "). .

Class Code Description
1xx : Informational 100 Continue
101 Switching Protocols
2xx : Success 200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No content
205 Reset Content
206 Partial Content
3xx : Redirection 300 Multiple Choices
301 Moved Permanently
302 Found/Moved Temporarily
303 See Other
304 Not Modified
305 Use Proxy
307 Temporary Redirect
4xx : Client Error 400 Bad Request
401 Unauthorized
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
408 Request Time-out
409 Conflict
410 Gone
411 Length Required
412 Precondition Failed
413 Request Entity Too Large
414 Request-URI Too Large
415 Unsupported Media Type
416 Requested range not satisfiable
417 Expectation Failed
5xx : Server Error 500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Server Unavailable
504 Gateway Time-out
505 HTTP Version not supported
extension-code xxx Reason-Phrase

Remarks:

The Response.Status property can be used to modify the status line as defined in the HTTP specification returned by the server to the client according to the needed.

The response HTTP status line may not be understanded by the HTTP application. But the clint should understand the class of status code, the first digit of the status code and any unrecognized status code is considered as being equivalent to the x00 status code of that class.

Examples:

  • Default value with No Response.Status

    ASP script command:

    <%  %>

    HTTP header response:

    HTTP/1.1 200 OK
    Server: Microsoft-IIS/5.1
    Date: Tue, 31 Jan 2012 15:19:08 GMT
    X-Powered-By: ASP.NET
    Content-Length: 0
    Content-Type: text/html
    Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
    Cache-control: private

  • Response.Status with value "301 Moved Permanently" to modify the status line of HTTP header

    ASP script command:

    <% Response.Status="301 Moved Permanently" %>

    HTTP header response: 

    HTTP/1.1 301 Moved Permanently
    Server: Microsoft-IIS/5.1
    Date: Tue, 31 Jan 2012 15:19:08 GMT
    X-Powered-By: ASP.NET
    Content-Length: 0
    Content-Type: text/html
    Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
    Cache-control: private

  • Response.Status with value "201 Created"  to specify the status line of HTTP header together with new created URI specified by Location HTTP header for redirection used by client with automatic redirection capability.

    ASP script command:

    <% Response.Status="201 Created" %>
    <% Response.AddHeader "Location","../../../Newdefault.asp" %>

    HTTP header response: 

    HTTP/1.1 201 Created
    Server: Microsoft-IIS/5.1
    Date: Tue, 31 Jan 2012 15:19:08 GMT
    X-Powered-By: ASP.NET
    Location: ../../../Newdefault.asp
    Content-Length: 0
    Content-Type: text/html
    Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
    Cache-control: private

  • Response.Status with value "301 Moved Permanently"  to specify the status line of HTTP header together with new permanent URI specified by Location HTTP header for redirection used by client with automatic redirection capability.

    ASP script command:

    <% Response.Status="301 Moved Permanently" %>
    <% Response.AddHeader "Location","../../../Newdefault.asp" %>

    HTTP header response: 

    HTTP/1.1 301 Moved Permanently
    Server: Microsoft-IIS/5.1
    Date: Tue, 31 Jan 2012 15:19:08 GMT
    X-Powered-By: ASP.NET
    Location: ../../../Newdefault.asp
    Content-Length: 0
    Content-Type: text/html
    Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
    Cache-control: private

Response.Redirect Method

Response.Redirect Method redirects the HTTP request to "a specified URL" by sending a 302 moved HTTP header to the client.

Syntax:

Response.Redirect(
    URL
)

 Or in an ASP file. Imply

<% Response.Redirect "URL" %>

Parameters:

URL

The parameter "URL" is the new Uniform Resource Locator (URL) to redirect. The data type of "URL" is an full URL or string of virtual path, absolute path to a location on the server or relative path to the original URL and is enclosed by quotation marks (" ").

Return Values:

The method has no return value. 

Remarks:

The parameter "URL" can include a query string.

Older Web browsers might convert a POST request to a GET request during a redirection.

The Output Content of the original URL is ignored and a redirection header is sent to the client as specified by the Response.Redirect. And an automatic repsonse body content with the redirection link of URL is also generated for those client without automatic redirection capability.

Examples:

  • Default value with No Response.Redirect

    ASP script command:

    <%  %>

    HTTP header response:

    HTTP/1.1 200 OK
    Server: Microsoft-IIS/5.1
    Date: Tue, 31 Jan 2012 15:19:08 GMT
    X-Powered-By: ASP.NET
    Content-Length: 0
    Content-Type: text/html
    Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
    Cache-control: private

  • Response.Redirect with value "../../../newpage.asp" to redirect the original URL to the specified URL

    ASP script command:

    <% Response.Redirect "../../../newpage.asp" %>

    HTTP header response: 

    HTTP/1.1 302 Object Moved
    Server: Microsoft-IIS/5.1
    Date: Tue, 31 Jan 2012 15:19:08 GMT
    X-Powered-By: ASP.NET
    Loction: ../../../newpage.asp
    Content-Length: 148
    Content-Type: text/html
    Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
    Cache-control: private

    HTTP response output: 

    <head><title>Object moved</title></head>
    <body><h1>Object Moved</h1>
    This object m ay be found <a HREF="../../../newpage.asp">here</a>.
    </body>


©sideway
close

References

  1. Active Server Pages, http://msdn.microsoft.com/en-us/library/aa286483.aspx, updated 20Dec2012
  2. ASP Overview, http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx, updated 21Dec2012
  3. ASP Best Practices, http://technet.microsoft.com/en-us/library/cc939157.aspx, updated 15Apr2013
  4. ASP Built-in Objects, http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx, updated 20Dec2012
  5. Response Object, http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx, updated 20Dec2012
  6. Request Object, http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx, updated 20Dec2012
  7. Server Object (IIS), http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx, updated 20Dec2012
  8. Application Object (IIS), http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx, updated 20Dec2012
  9. Session Object (IIS), http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx, updated 20Dec2012
  10. ASPError Object, http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx, updated 20Dec2012
  11. ObjectContext Object (IIS), http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx, updated 20Dec2012
  12. Debugging Global.asa Files, http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx, updated 15Apr2013
  13. How to: Debug Global.asa files, http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx, updated 15Apr2013
  14. Calling COM Components from ASP Pages, http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx, updated 15Apr2013
  15. IIS ASP Scripting Reference, http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx, updated 15Apr2013
  16. ASP Keywords, http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx, updated 15Apr2013
  17. Creating Simple ASP Pages, http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx, updated 15Apr2013
  18. Including Files in ASP Applications, http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx, updated 15Apr2013
  19. ASP Overview, http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx, updated 15Apr2013
  20. FileSystemObject Object, http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx, updated 14Mayr2013
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx, ADO Object Model, updated 15Apr2013
  22. ADO Fundamentals, http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx, updated 14Mayr2013
close

ID: 120200006 Last Updated: 2/4/2012 Revision: 0 Ref:

IMAGE

Home (5)

Business

Management

HBR (3)

Information

Recreation

Hobbies (7)

Culture

Chinese (1097)

English (336)

Reference (66)

Computer

Hardware (149)

Software

Application (187)

Digitization (24)

Numeric (19)

Programming

Web (644)new

CSS (SC)

ASP.NET (SC)

Regular Expression (SC)

HTML

Knowledge Base

Common Color (SC)

Html Entity (Unicode) (SC)

Html 401 Special (SC)

OS (389)new

MS Windows

Windows10 (SC)

.NET Framework (SC)

DeskTop (7)

Knowledge

Mathematics

Formulas (8)

Number Theory (206)

Algebra (20)

Trigonometry (18)

Geometry (18)

Calculus (67)

Complex Analysis (21)

Engineering

Tables (8)

Mechanical

Mechanics (1)

Rigid Bodies

Statics (92)

Dynamics (37)

Fluid (5)

Fluid Kinematics (5)

Control

Process Control (1)

Acoustics (19)

FiniteElement (2)

Biology (1)

Geography (1)

Latest Updated Links

Copyright © 2000-2019 Sideway . All rights reserved Disclaimers last modified on 10 Feb 2019