Guest User

Untitled

a guest
Nov 16th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. byte[] theData = doc.GetData();
  2. Response.ClearHeaders();
  3. Response.ClearContent();
  4. Response.Expires = -1000;
  5. Response.ContentType = "application/pdf";
  6. Response.AddHeader("content-length", theData.Length.ToString());
  7. Response.AddHeader("content-disposition", "attachment; filename=test.pdf");
  8. Response.BinaryWrite(theData);
  9. HttpContext.Current.ApplicationInstance.CompleteRequest();
  10.  
  11. 'HttpResponse' does not contain a definition for 'ClearHeaders'
  12. 'HttpResponse' does not contain a definition for 'ClearContent'
  13. 'HttpResponse' does not contain a definition for 'Expires'
  14. 'HttpResponse' does not contain a definition for 'AddHeader'
  15. 'HttpResponse' does not contain a definition for 'BinaryWrite'
  16. 'HttpContext' does not contain a definition for 'Current'
  17.  
  18. [Route("api/[controller]")]
  19. public class PDFController : Controller {
  20. // GET: api/<controller>
  21. [HttpGet]
  22. public IActionResult Get() {
  23. using (Doc theDoc = new Doc()) {
  24. theDoc.FontSize = 96;
  25. theDoc.AddText("Hello World");
  26. Response.Headers.Clear();
  27. Response.Headers.Add("content-disposition", "attachment; filename=test.pdf");
  28. return new FileStreamResult(theDoc.GetStream(), "application/pdf");
  29. }
  30. }
  31. }
Add Comment
Please, Sign In to add comment