answersLogoWhite

0


Best Answer
Let's remember the very first ASP script written, the one that looked like this:

Response.Write("Hello World!")

Now, try to guess what response and write() are. Of course, response is a built-in object of ASP, while write() is one of its methods. You can introduce HTML tags in the string, it will be interpreted correctly:

Response.Write(" Hello World! ")

The response object can do things far more powerful than write text and ad HTML code to your page. As the name implies, its function is to send a response to the user, an output from the server. Now, this brings us one huge step closer to the initial goal of learning ASP, that is, to allow the creation of dynamic, interactive web pages.

For instance, one property for the response object is called ContentType. By default this is set to text/html, but you can change it to anything else, such as image, or a specific type of image, like JPEG or GIF, or a certain application. Let's take a look at the following example:

<% Response.ContentType="application/vnd.ms-excel" %>

Excel Table

Washington

Paris

London

Moscow

As you can see, this is a simple HTML table, but the user will see it as an Excel table, as long as this piece of software is installed on the respective computer. If it's not installed, then, well, it wasn't such a great idea. You can use this feature to constrain the user to viewer to use a certain program, or to constrain the content to accept only a certain type of input.

You've seen the message "404 Not Found" hundreds of times on the internet. It is caused by a property of the response object, called Status. It is often found in a conditional statement, such as If the ip address is . then Response.Status="404 Not Found" or "401 Unauthorized".

Another property is Expires, which establishes a period of time (expressed in minutes) to keep a page cached on a browser before it expires. There is also a version of this property called ExpiresAbsolute, which does the same, but sets a specific date and time for the page to expire. If you don't want the page to be cached at all, you can set the Expires property to a negative value.

Response.Expires = -1

The Buffer property decides whether to buffer the content of the page - meaning that the server will not allow the user to load the content of the page until it processes all the server scripts, or until it runs the methods Flush or End. If you want to use this method, you need to place it before the actual HTML code, and set it to "true". For the earlier versions of IIS (before 5.0), this was set by default to "false", but in the 5.0 and later versions, the default is "true". This is useful if you want the browser to finish performing a loop before showing anything to the user.

We've already met two methods of the response object, End and Flush. The End method puts an end to the script, and returns the result processed until the respective moment. The Flush method sends the HMTL content that has already been buffered without any delay (without waiting for the rest of the content to be buffered as well).

One method that is quite common is the Redirect, looking like this:

Response.Redirect("http://www.softwareprojects.org")

Now let's take a look at the request object, used to obtain information from the user. It is really valuable in connection with forms, as shown in the following chapter. It has a property called TotalBytes, which returns the number of bytes sent by the client's request. This is read-only, as you cannot modify this value:

X = Request.TotalBytes

After this, you can use the method called BinaryRead(a), to retrieve the data the user sent to the server as part of a POST request. The data will be stored in safe array. You need to specify the parameter a, which is how many bites you want the method to read from the user (value usually equal to the X variable returned by the TotalBytes property above).

Besides all these, the Request object also has collections, including ServerVariables (containing all the server variables), QueryString (with all the variables in a HTTP query string), forms and cookies, which are the most important, and will be discussed in the following chapters.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are request and response objects?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Why should one write their own HTTP module in asp net?

HTTP Modules like HTTP handlers are used to extend the HTTP pipeline. These are basically classes implementing the IHTTPModule Interface. These modules are used to process the incoming requests. Hence they can perform certain operations based on the requests and further allow them to pass through the pipeline.For example we can write HTTP Modules to implement security. One can register the incoming requests for certain events with the help of such modules. These are listeda s below: -EventWhen It's CalledBeginRequestBefore request processing startsAuthenticateRequestTo authenticate clientAuthorizeRequestTo perform access checkResolveRequestCacheTo get response from cacheAcquireRequestStateTo load session statePreRequestHandlerExecuteBefore request sent to handlerPostRequestHandlerExecuteAfter request sent to handlerReleaseRequestStateTo store session stateUpdateRequestCacheTo update response cacheEndRequestAfter processing endsPreSendRequestHeadersBefore buffered response headers sentPreSendRequestContentBefore buffered response body sentApplication_OnStartThis event is raised when the very first request arrives to the Web application.Application_OnEndThis event is raised just before the application is going to terminate.Session_OnStartThis event is raised for the very first request of the user's session.Session_OnEndThis event is raised when the session is abandoned or expired.


How do you say class objects in french?

Class objects or Glass Objects? Class Objects is objets de classe Glass objects is objets en verre


How are server-side scripts executed?

That depends on the type of coding done on server side scripts. Sometimes they need a request object from client-side to initiate the scripts to provide response while other times there are bots which initiate the server side script without a request object.An example of automated scripts execution is deleting a user who registered before 24 hours but did not confirm his e-mail.


What is session in java?

Why do we need a Session?When one page needs to share information with another, the scope of the data broadens beyond processing a single request. This is because, when a response gets committed, all the data that was held in the request that generated that response is destroyed. So, if you want that data in another page, you will be looking at a blank request object with no data in it. When such a need arises, you must send the data from one page to the server and from the server to the next requested page, whether it be the same page or another page altogether. There are several ways to share state information between requests. However, the primary or the easiest way is to use sessions.How Do Sessions Work?The container generates a session ID. When you create a session, the server saves the session ID on the client's machine as a cookie. If cookies are turned off then it appends the ID in the URL. On the server, whatever you add to the session object gets placed in server memory-very resource intensive. The server associates that object in memory with the session ID. When the user sends a new request, the session ID is sent too. The server can then match the objects in its memory with that session ID. This is how we maintain client state.


What is difference between HttpModule and HttpHandler?

HTTP handlers are the end point objects in ASP.NET pipeline and an HTTP Handler essentially processes the request and produces the response. For example an ASP.NET Page is an HTTP Handler. HTTP Modules are objects which also participate the pipeline but they work before and after the HTTP Handler does its job, and produce additional services within the pipeline (for example associating session within a request before HTTP handler executes, and saving the session state after HTTP handler has done its job, is basically done by an HTTP module, SessionStateModule) HTTP handlers HTTP handlers are the .NET components that implement the System.Web.IHttpHandler interface. Any class that implements the IHttpHandler interface can act as a target for the incoming HTTP requests. HTTP handlers are somewhat similar to ISAPI extensions. One difference between HTTP handlers and ISAPI extensions is that HTTP handlers can be called directly by using their file name in the URL, similar to ISAPI extensions. HTTP Modules http://blbirajdar.blog.co.in HTTP modules are .NET components that implement the System.Web.IHttpModule interface. These components plug themselves into the ASP.NET request processing pipeline by registering themselves for certain events. Whenever those events occur, ASP.NET invokes the interested HTTP modules so that the modules can play with the request.

Related questions

Http servlet response and http request?

HttpServletRequest and HttpServletResponse are the two objects that signify the request received by a servlet and the response sent by it after it is done processing the request. Both the request and response can carry data objects (variables) that can be accessed by the entity receiving the request/response object. They are both an integral part of J2EE Applications.


How many in built objects are there in ASPNet?

there are 6 objects. 1. server 2. session 3. application 4. ObjectContext 5. Response 6. Request


Does a user request a web page that consists of some text and two images for this page the client will send one request message and receive three response messages?

False, as there are a total of 3 objects. User needs to send 3 request message and will get 3 response message.


Which of the following are ASP standard objects A images B Request C Response D Server E Session F Application G Hardware Choose any that apply?

B Request C Response D Server E Session F Application


What is grammatically correct - we are looking forward to your positive response to this request on this request or for this request?

&quot;We are looking forward to your positive response to this request.&quot; This is the grammatically correct phrase. &quot;On this request&quot; or &quot;for this request&quot; would not be necessary for conveying the intended meaning.


What is Request-response paradigm?

request response paradigm is somthiing which define how request and response work in the web application or in real world. First when the user open browser and hit any URL, request object is created. This request object then send to the server. server finds the appropriate resources for that request and executes the logic (if any) ans send back response to the browser. Browser interprets the response and display result


What are turnaround time and response time with reference to Operating System?

Turnaround time is the interval between the submission of a job and its completion. Response time is the interval between submission of a request, and the first response to that request.


What object is used to request data from a form in ASP?

Response


What is the term for the delay in the RAM's response to a request from the MCC?

Latency


What is JSP Implicit objects?

In any JSP Page, there are a bunch of implicit objects that are available for the programmer to use. It contains a variety of information that can be used to display stuff on the page. The following JSP Implicit Objects are available for a programmer: &acirc;&euro;&cent; request &acirc;&euro;&cent; response &acirc;&euro;&cent; out &acirc;&euro;&cent; session &acirc;&euro;&cent; config &acirc;&euro;&cent; application &acirc;&euro;&cent; page &acirc;&euro;&cent; pageContext


How many objects are there in ASP?

There 7 types of objects in asp There are 1)application object 2)session object 3)request object 4)response object 5)server object 6)object context object 7)Error object(it is the new object included in asp 3.0)


What is Scrooge's response when the visiting gentlemen request a donation for the poor?

"Hmmph".