//public void OnGet() //{ // this.Content = OfferteModelsForTesting.TestModel(); //} public void OnPost() { var serializeExample = JsonSerializer.Serialize(OfferteModelsForTesting.TestModel()); var itemsJson = Request.Form["items"].First(); Content = JsonSerializer.Deserialize <OfferDocumentModel>(itemsJson); }
public async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequest req, ILogger log) { log.LogInformation($"Browser path: {_appInfo.BrowserExecutablePath}"); var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true, ExecutablePath = _appInfo.BrowserExecutablePath }); var page = await browser.NewPageAsync(); await page.GoToAsync($"http://localhost:{_appInfo.RazorPagesServerPort}/"); var data = JsonSerializer.Serialize(OfferteModelsForTesting.TestModel()); OfferteModelsForTesting.TestModel(); await page.TypeAsync("#items-box", data); await Task.WhenAll( page.WaitForNavigationAsync(), page.ClickAsync("#submit-button")); var stream = await page.PdfStreamAsync(); await browser.CloseAsync(); return(new FileStreamResult(stream, "application/pdf")); }