What is the main use of Response.Output.Write()?

Answer Posted / varun

In ASP.NET the Response object is of type HttpResponse and
when you say Response.Write you're really saying
(basically) HttpContext.Current.Response.Write and calling
one of the many overloaded Write methods of HttpResponse.

Response.Write then calls .Write() on it's internal
TextWriter object:

public void Write(object obj){ this._writer.Write(obj);}

HttpResponse also has a Property called Output that is of
type, yes, TextWriter, so:

public TextWriter get_Output(){ return this._writer; }

Which means you can to the Response whatever a TextWriter
will let you. Now, TextWriters support a Write() method
ala String.Format, so you can do this:

Response.Output.Write("Scott is {0} at
{1:d}", "cool",DateTime.Now);

But internally, of course, this this is happening:

public virtual void Write(string format, params object[]
arg)
{
this.Write(string.Format(format, arg));
}

Is This Answer Correct ?    10 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you identify that the page is post back?

539


5. What three Specific Job Positions do you target from Swatz Oils GROUP U.K?

1754


How many validators do ASP.NET have?

595


Can you use Web API with ASP.NET Web Form?

680


Why mvc is better than asp.net? : Asp.Net MVC

459






Why session management is required?

523


Define a multilingual website?

522


What is a viewbag?

497


What is the importance of Global.asax in ASP.NET?

544


What are the modes of updation in an updatepanel?

545


What is postback request?

543


What are the two Layouts supported by a Web form in ASP.NET?

545


there is two functions function a and function b like fun a(){.... ..... } fun b() { } in function b i write the coding to add two numbers and i need to dispaly the sum result in function a with out using global variable. how we do?

2210


How to deploy/publish webservices?How many ways?Plz explain me

1826


How can we create pie chart in asp.net?

571