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: 2/4/2012 Revision: 0 Ref:

close

References

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

Culture

Chinese 1097

English 339new

Travel 7new

Reference 79

Computer

Hardware 251

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 431

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Set 1

Logic 1

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

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

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


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