Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Microsoft.Playwright in your ASP.NET Core application: launch a browser, navigate a page to the target URL, then call Page.ScreenshotAsync. Set FullPage = true for the full scrollable page, or use Locator.ScreenshotAsync for one element. The screenshot API can save to a file or return image bytes for an HTTP response or further processing.

Capture a webpage with Playwright in ASP.NET Core

The following is the core browser-automation sequence from Microsoft’s .NET guide. It captures the viewport and saves a PNG. Replace the URL and output path with values appropriate to your application.

using Microsoft.Playwright;

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();
await page.GotoAsync("https://example.com");
await page.ScreenshotAsync(new() { Path = "screenshot.png" });

See the Playwright .NET library guide for setup and browser installation, and the screenshot guide for capture options. In a web application, adapt the sample to your hosting model and manage browser and page lifetimes accordingly; the basic library example is not, by itself, a production deployment or security design.

Install the package and browser

  1. Create or open the .NET project that will run the capture code.
  2. Add the Microsoft.Playwright package, then build the project.
  3. Run the Playwright browser-install script generated for the target .NET output so Chromium is available where the application runs. Follow the current library setup guide for the exact commands and target-specific details.
  4. Run the capture code in an asynchronous context and confirm that the process can write to the chosen output location.

The browser binaries are a separate runtime requirement from the NuGet package. Installing the package alone does not install every browser binary your deployment needs.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Return the screenshot as bytes

If the application needs to return the image rather than write a file, omit Path. ScreenshotAsync returns a byte[], which can be sent as the body of an ASP.NET Core response or passed to another component.

using Microsoft.Playwright;

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();
await page.GotoAsync("https://example.com");

byte[] image = await page.ScreenshotAsync();
return Results.File(image, "image/png");

This minimal endpoint-style example shows how to use the returned bytes; it does not add request validation, error handling, or resource limits. Those concerns matter if the URL comes from an HTTP request.

Choose viewport, full-page, or element capture

Viewport screenshot

The default page screenshot captures the visible viewport. You can write it to a path or omit the path and process the returned bytes. This is appropriate when the required image is exactly what fits in the browser window.

Full scrollable page

Set FullPage to true to capture the page’s full scrollable extent as if it were displayed on a very tall screen:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
byte[] image = await page.ScreenshotAsync(new()
{
    FullPage = true
});

A full-page image can be much larger than a viewport image. Consider the output size and how the receiving application will store or deliver it.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

One element

Use a locator’s screenshot method when the output should be limited to a particular element:

var card = page.Locator(".product-card");
byte[] image = await card.ScreenshotAsync();

The locator screenshot waits for actionability checks and scrolls the element into view. It cannot make an obstructed element visible: if another element covers it, the capture may not show it as intended. For a scrollable container, the screenshot includes only the content currently scrolled into view, not every item hidden inside that container. See the Locator API documentation.

Set the image format and visual output

Playwright documents PNG, JPEG, and WebP screenshots, along with clipping, image quality for lossy formats, CSS-pixel or device-pixel scaling, transparent backgrounds, and animation control. PNG does not use the lossy quality setting; quality applies to JPEG and WebP. Consult the Page API documentation for the available options and their exact names.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Format: select PNG, JPEG, or WebP according to the consumer’s supported formats and the image characteristics.
  • Quality: use the documented quality setting for JPEG or WebP when a lossy image is acceptable; it does not change PNG output.
  • Scale: choose CSS-pixel or device-pixel scaling based on whether dimensions should follow CSS layout pixels or the browser’s device scale.
  • Clip: use a clip area when only a defined region of the page is needed without targeting a locator.
  • Transparency: the API supports an optional transparent background when the output and page styling make that useful.
  • Animation: disable animations when motion would make repeated captures vary. An injected stylesheet can also change or hide dynamic elements.

These controls can improve consistency, but the API options do not guarantee that every site will render identically across captures. Application-specific scripts, content, and timing can still affect appearance.

Make captures more repeatable

Pages can change while they load or between visits. For visual comparisons, decide in advance which elements or motion should appear, then use the screenshot API’s animation control or injected stylesheet to control presentation. A stylesheet can hide a changing banner or adjust an element for capture, but altering the page also means the resulting image no longer shows the unmodified presentation.

Choose the capture scope deliberately: a viewport image, a full-page image, and an element image answer different questions. For an element that is covered, first address the covering content or the page state; a locator screenshot does not bypass visibility problems. For scrollable containers, move the container to the desired content before capturing if the currently visible portion is not the one needed.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Use Playwright or PuppeteerSharp?

For a .NET project, choose based on browser coverage and fit with the application rather than assuming one library is universally faster or more reliable. The Playwright .NET project describes one API for Chromium, Firefox, and WebKit. PuppeteerSharp is a .NET port for controlling Chrome or Chromium and lists screenshots and PDF generation among its uses.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Library Documented browser coverage Relevant documented use Source
Microsoft.Playwright Chromium, Firefox, and WebKit Browser automation and screenshots Playwright .NET README
PuppeteerSharp Chrome or Chromium Screenshots and PDF generation PuppeteerSharp NuGet page

The cited project descriptions establish these differences in stated browser coverage and uses; they do not establish a universal performance or reliability winner.

Common screenshot problems and fixes

The browser fails to launch

Check that the Playwright package is installed and that the browser-install step has run for the application’s target output and runtime environment. The .NET library guide explains the setup sequence. A working build does not prove that the required browser binary is available when the application starts.

The image is empty or the page is incomplete

Confirm that navigation reached the intended page and that the capture scope matches the goal. A default screenshot is a viewport image, not the whole document; set FullPage = true when the full scrollable extent is required. If the page has application-specific loading behavior, a screenshot call alone does not guarantee that all dynamic content has reached its final state.

The element screenshot misses content

Check whether another element covers the target. Locator screenshots perform actionability checks and scroll the element into view, but do not remove an overlay. If the target is inside a scrollable container, only its currently scrolled content appears; move the container to the desired position before capture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Repeated images differ

Dynamic content and animation can change between captures. Use the documented animation option or an injected stylesheet where appropriate, and verify that any styling changes still represent the result you want. Playwright’s documentation describes these controls but does not promise application-specific determinism.

The file is not created

When using the Path option, verify the process’s write access and the path available in the environment where the application runs. If the application needs to return the image instead, omit the path and handle the byte array returned by the method.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Production considerations for ASP.NET Core

The short Playwright sample demonstrates how to automate a browser; it does not establish safe production settings for a service that accepts arbitrary URLs, browser isolation, or resource management at scale. Treat those as separate deployment and security decisions rather than assuming the sample is ready to expose as a public screenshot endpoint.

  • Decide which callers may request captures and which destinations the application is allowed to navigate to.
  • Choose how browser and page instances are managed for the service’s hosting model; the documentation example’s local lifecycle is not a complete hosting strategy.
  • Set operational limits appropriate to the application, including how large an output it can accept and how long a request can occupy resources.
  • Handle navigation and capture failures explicitly so an unsuccessful render is not treated as a valid image.

These are implementation areas to evaluate for your deployment. The cited API and setup documentation does not prescribe a complete security or scale configuration for arbitrary-URL capture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

If you do not want to install and operate browser binaries, ScreenshotNeo provides a website screenshot API. One GET request can return an image or PDF. For example, this cURL command requests a WebP screenshot:

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request parameters and response details. ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents use screenshot tools. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Learn about ScreenshotNeo, or sign up free for 1,000 screenshots a month with no card.

Frequently Asked Questions

Can Playwright save a screenshot directly to a C# byte array?

Yes. Omit the screenshot path and use the byte array returned by ScreenshotAsync.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I capture a full webpage rather than the visible browser window?

Yes. Set FullPage = true on the page screenshot options.

Does a locator screenshot include every item inside a scrollable container?

No. It captures the content currently scrolled into view within that container.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.