What is difference between Responce.write() and Responce.output.write().
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sandeep KumarPosted Aug 18, 2015, 9:05 AM
The difference between
Response.Write()andResponse.Output.Write()in ASP.NET. The short answer is that the latter gives youString.Format-styleoutput and the former doesn't. The long answer follows.In ASP.NET the
Responseobject is of typeHttpResponseand when you sayResponse.Writeyou're really saying (basically)HttpContext.Current.Response.Writeand calling one of the many overloadedWritemethods ofHttpResponse.Response.Writethen calls.Write()on it's internalTextWriterobject:HttpResponsealso has a Property calledOutputthat is of type, yes,TextWriter, so:Which means you can to the
Responsewhatever aTextWriterwill let you. Now, TextWriters support aWrite()method alaString.Format, so you can do this:But internally, of course, this this is happening:
Santhakumar MunuswamyPosted Aug 17, 2015, 3:38 PM
Rajeesh MenothPosted Aug 17, 2015, 12:34 PM
Upendra Pratap ShahiPosted Aug 17, 2015, 11:57 AM
But their are is a difference between both of them
1. Response.Output.Write() is allows us to print formatted output but Response.Write() can't allows the formatted output.
Example:
Response.Output.Write(".Net{0},"ASP"); // Its write
Response.Write(".Net{0},"ASP"); // Its Wrong
2. As Per Asp.Net 3.5, Response.Write() Has 4 overloads, with Response.Output.Write()
has 17 overloads.