how to make code execute after Response.end

后端 未结 4 1167
感动是毒
感动是毒 2021-01-03 11:53

My code is like this

HttpContext.Current.Response.Clear();
     HttpContext.Current.Response.ContentType = \"application/pdf\";
     HttpContext.Current.Resp         


        
4条回答
  •  太阳男子
    2021-01-03 12:44

    // Add headers for a csv file or whatever
    Response.ContentType = "text/csv"
    Response.AddHeader("Content-Disposition", "attachment;filename=report.csv")
    Response.AddHeader("Pragma", "no-cache")
    Response.AddHeader("Cache-Control", "no-cache")
    
    // Write the data as binary from a unicode string
    Dim buffer As Byte()
    buffer = System.Text.Encoding.Unicode.GetBytes(csv)
    Response.BinaryWrite(buffer)
    
    // Sends the response buffer
    Response.Flush()
    
    // Prevents any other content from being sent to the browser
    Response.SuppressContent = True
    
    // Directs the thread to finish, bypassing additional processing
    HttpContext.Current.ApplicationInstance.CompleteRequest()
    

提交回复
热议问题