filip
filip

Reputation: 1513

Connect to existing browser using Playwright for .Net

We have a single Asp Core API method that is transforming provided html into PDF using headless Chromium. Currently the API method is using Puppeteer, which connects to an existing instance of Chromium using the debugging port and generates the PDF. Chromium needs to be launched before or on application start. All this works fine.

We are now considering rewriting the API to use Microsoft.Playwright instead of the Puppeteer. However, it seems that with Playwright for .Net we can't connect to an existing browser instance and we always need to use BrowserType.LaunchAsync, which creates a new instance. I can see the BrowserType.Connect available for all other APIs (node, python, java) but not for .Net.

Is there a way to avoid launching a new browser for every API request using the .Net Playwright API? It is very time-consuming and performance is very important in our case.

Upvotes: 2

Views: 1793

Answers (0)

Related Questions