Given an MVC controller method, that builds and returns a PDF.
[HttpGet]
[Route("pdf/{acc}/{sign}")]
public async Task<ActionResult> Download(string acc, string sign)
{
... // omitted some irrelevant detail.
var html = this.View("Letter", model).Capture(this.ControllerContext);
byte[] pdf = this.CreatePdfFromHtml(html);
return this.File(binary, "application/pdf", file);
}
The Capture extension method captures the html output, which is then returned as a file.
I need to execute the above method (or something close) in the below webapi2 method. I need the credentials and other login state to be present. The webapi and MVC requests are within the same application that uses cookies for security.
[HttpPost]
[Route("generate")]
public int Generate(MyRequestModel request)
{
byte[] pdf = ... // how do i get the file above??
}