Response.End()

Response End

This is added after the text needed in the response stream is written using the Response.Write() so no other html or garbage is written in the response stream.

Without response.end() javascript will have the text and the remaining garbage.

[ex. 1] without response.end()

Response.Write(“err”);
…..
result =”err

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml&#8221; ><head><link href=”../App_Themes/Default/Content.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/Default.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/EmailSender.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/Header.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/Header2.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/Sidebar.css” type=”text/css” rel=”stylesheet” /><title> </title></head><body>    <form name=”form1″ method=”post” action=”WebService.aspx” id=”form1″><div><input type=”hidden” name=”__VIEWSTATE” id=”__VIEWSTATE” value=”/wEPZwUPOGNjY2JiNjJiNWQ5MDI41In2qlnOWzD0wbpAPF80y1dPYTA=” /></div>
</form></body></html>”

[ex. 2] with Reponse.End()

Response.Write(“err”);
Response.End();
…..
result = “err”

So it’s better using Response.End()…I think. This is mostly used in conjunction with calling a web service from javascript . I also found something about HttpContext.Current.ApplicationInstance.CompleteRequest(); which can be used instead of Response.End(); but didn’t go much into it. If you have more info re this or why it’s better, feel free to comment.

More info re HttpContext.Current.ApplicationInstance.CompleteRequest(); can be found here and here.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: