title: HttpContext.Current.Response.End() skip the execution
body: <p>I am exporting my <code>gridview</code> to excel sheet through <code>JavaScript</code> using <code>webmethod</code>. Since all the rows in the <code>gridview</code> contains template controls like <code>label,anchor,etc</code>., which are created at runtime through <code>JavaScript</code> not at design, I use to pass all the rows by array to web method. To export I have created a table and map the array returned by the <code>JavaScript</code> function. But the problem is while debugging, the execution is skipped on <code>httpContext.Current.Response.End</code> and also I couldn't export the grid. I don't know why its happening. below is my code of web method</p>
  
  <pre><code>&lt;WebMethod(EnableSession:=True, transactionOption:=EnterpriseServices.TransactionOption.RequiresNew)&gt; _
  &lt;ScriptMethod(ResponseFormat:=ResponseFormat.Xml, usehttpget:=True)&gt; _
  Public Shared Sub XlExport(ByVal fileName As String, ByVal row As Object()())
      HttpContext.Current.Response.Clear()
      HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", fileName))
      HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
      Dim sw As StringWriter = New StringWriter
      Dim htw As HtmlTextWriter = New HtmlTextWriter(sw)
      Dim table As Table = New Table
      table.GridLines = GridLines.Both
      For i As Integer = 0 To row.Length - 1
          Dim dr As New TableRow
          For j As Integer = 0 To row(i).Length - 1
              Dim dc As New TableCell
              Dim lt As New LiteralControl
              lt.Text = row(i)(j)
              dc.Controls.Add(lt)
              dr.Cells.Add(dc)
          Next
          table.Rows.Add(dr)
      Next
      table.RenderControl(htw)
      HttpContext.Current.Response.Write(sw.ToString)
      HttpContext.Current.Response.End()
  End Sub
  </code></pre>