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","http://127.0.0.1/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: http://127.0.0.1/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","http://127.0.0.1/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: http://127.0.0.1/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 "http://127.0.0.1/newpage.asp" to redirect the original URL to the specified URL

    ASP script command:

    <% Response.Redirect "http://127.0.0.1/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: http://127.0.0.1/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="http://127.0.0.1/newpage.asp">here</a>.
    </body>


©sideway

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

close

References

  1. Active Server Pages,  
  2. ASP Overview,  
  3. ASP Best Practices,  
  4. ASP Built-in Objects,  
  5. Response Object,  
  6. Request Object,  
  7. Server Object (IIS),  
  8. Application Object (IIS),  
  9. Session Object (IIS),  
  10. ASPError Object,  
  11. ObjectContext Object (IIS),  
  12. Debugging Global.asa Files,  
  13. How to: Debug Global.asa files,  
  14. Calling COM Components from ASP Pages,  
  15. IIS ASP Scripting Reference,  
  16. ASP Keywords,  
  17. Creating Simple ASP Pages,  
  18. Including Files in ASP Applications,  
  19. ASP Overview,  
  20. FileSystemObject Object,  
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx,  
  22. ADO Fundamentals,  
close

Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 7

Culture

Chinese 1097

English 337

Reference 67

Computer

Hardware 149

Software

Application 187

Digitization 24

Numeric 19

Programming

Web 757

CSS 1

ASP.NET 1

Regular Expression 1

HTML

Knowledge Base

Common Color 1

Html Entity (Unicode) 1

Html 401 Special 1

OS 389

MS Windows

Windows10 1

.NET Framework 1

DeskTop 7

Knowledge

Mathematics

Formulas 8

Algebra 20

Number Theory 206

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

Physics

Electric 10

Biology 1

Geography 1


Copyright © 2000-2019 Sideway . All rights reserved Disclaimers last modified on 06 September 2019