Capture the element in the browser with html2canvas, export the canvas as PNG bytes, post those bytes with jQuery, and let an authenticated ASP.NET action validate and store them under a server-generated name. This workflow saves an image of a DOM reconstruction; it is not a native, pixel-perfect browser screenshot.
The complete workflow
The reliable sequence is:
- Choose the element, such as
#capture. - Call
html2canvas(element)after the content and fonts are ready. - Export PNG data with
canvas.toDataURL('image/png')for a small, simple payload, orcanvas.toBlob()for larger uploads. - POST the result to an ASP.NET endpoint with jQuery.
- On the server, authenticate the request, enforce a byte limit, verify the PNG signature, generate the filename, and save outside executable web paths.
html2canvas runs entirely in the browser and returns a Promise that resolves to a canvas. It rebuilds an image from the DOM and supported CSS, so effects or content unavailable to the page may not appear exactly as they do on screen.
Prepare the page
Markup and libraries
Give the region a stable selector. Load jQuery and a built html2canvas release (or install the package from npm and bundle it):
<button id="save-shot" type="button">Save screenshot</button>
<div id="capture">
<h1>Invoice preview</h1>
<p>This entire region will be rendered to PNG.</p>
</div>
<div id="status" role="status"></div>
<script src="/lib/jquery/jquery.min.js"></script>
<script src="/lib/html2canvas/html2canvas.min.js"></script>
Wait until the element has its final text, images and layout. If a web font or image is still loading, the canvas can capture the earlier state.
#1 Best Overall
- 【1080P 60FPS Video Capture Card】 This HDMI game capture card is based on USB3.0 high speed transmission port, input resolution up to 4K@30HZ, output resolution up to 2K@30Hz or 1920×1080@60Hz. Type c and USB interface can meet most of the devices in daily life. Easily meet the online capture, real-time recording, online meetings, live gaming and other functions, so you have a better visual enjoyment. Note: For capture use only; requires capture software to function and is not intended for direct screen casting to a monitor or TV
- 【Ultra Low Latency Screen Sharing】 HDMI capture card is made of good quality aluminum alloy with strong heat dissipation, allowing you to enjoy ultra low latency while live gaming or video recording or live streaming, avoiding blue screens and lag. This HDMI to USBC capture card supports easy recording of good quality audio or HD video and transferring it to your computer or streaming platform, allowing you to record 60 fps HD video directly on your hard drive and real-time preview
- 【Plug and Play, Easy to Carry】 This HDMI 1080P video capture card does not require any additional drivers or external power supply, just plug and play for fast capture. The capture card is small and lightweight, so you can put it in your bag for emergencies, making it very portable for outdoor live streaming. It's also a great way to share content in game recording, video conference, video recorder and online teaching
- 【Wide Compatibility USB Capture Card】 Easily streams to Facebook, Youtube or Twitch. With the connection, this HDMI to USB C/3.0 video capture devices can be working on several Operating Systems and various software: Windows 7/ 8/ 10, Mac OS or above, Linux, Android, Laptop, Xbox One, PS3/PS4/PS5, Camera, DVDs, Set Top Box, Webcame, DSLR, Switch/Switch 2, TV BOX, HDTV, Potplayer/VLC, ZOOM, OBS Studio etc.
- 【Package Content & Note】 1x HD Audio Capture Card , 1x USB 3.0 to USB C Adapter (A-side 3.0, B-side 2.0), 1x user manual. Please note that you need to restart the OBS Studio software after the audio setup is complete, otherwise it will result in no sound output. When using an adapter, if the device is recognized as USB 2.0, try using the other side with the USB-C port. Simply flip the capture card and reconnect it to be recognized as USB 3.0
Option 1: send a PNG data URL
This is the shortest implementation and works well for modest images. The prefix must be removed before server-side Base64 decoding.
$('#save-shot').on('click', function () {
var element = document.querySelector('#capture');
html2canvas(element, {
useCORS: true,
windowWidth: element.scrollWidth,
windowHeight: element.scrollHeight
}).then(function (canvas) {
var dataUrl = canvas.toDataURL('image/png');
$.ajax({
type: 'POST',
url: '/Screenshot/Save',
data: { imageData: dataUrl },
timeout: 90000,
success: function (result) {
$('#status').text('Saved: ' + result.url);
},
error: function (xhr) {
$('#status').text('Save failed (' + xhr.status + ').');
}
});
}).catch(function (error) {
$('#status').text('Capture failed.');
console.error(error);
});
});
Use an anti-forgery token if your ASP.NET application requires one. A common MVC pattern is to render @Html.AntiForgeryToken() and send its value in the request, or configure the endpoint to accept the token in a request header.
Option 2: upload a Blob with multipart form data
A Blob avoids putting the entire Base64 string in a form field. It is usually the better choice as screenshots get larger.
html2canvas(document.querySelector('#capture'), { useCORS: true })
.then(function (canvas) {
canvas.toBlob(function (blob) {
if (!blob) {
throw new Error('The browser could not create a PNG blob.');
}
var form = new FormData();
form.append('file', blob, 'capture.png');
$.ajax({
type: 'POST',
url: '/Screenshot/SaveMultipart',
data: form,
processData: false,
contentType: false,
timeout: 90000,
success: function (result) {
console.log('Saved: ' + result.url);
}
});
}, 'image/png');
});
The client-supplied name is only a form label. The server must not use it as a path or as proof of the file type.
Rank #2
- AV TO USB Converter: Capture videos and audios from VHS, VCR, Hi8, DV tapes to a PC, with the help of our USB Video Converter. Save room while digitizing your favorite old memories
- Quality Capture Card: Our USB Video Capture Card converting anolog RCA composite input into HD 720P USB output and capturing audio without any sound card. Advanced signal processing technology provides you with great precision, colors, resolutions, and details.
- Plug and Play: Automatically install the driver once you hook up this RCA to USB Converter to a PC. No external power is needed. User-friendly and easy to operate
- Wide Compatibility: The Video Capture Card can work with video devices with RCA connector or S-Video connector, such as VHS, VCR, Hi8, camcorder, compatible with Windows and Mac OS. Support video formats like NTSC, PAL, and support brightness, contrast, hue, and saturation control
- Note: The Video Converter is used with acquisition software. We recommend OBS Studio or PotPlayer for Windows, and QuickTime Player for Mac. They can be downloaded for free online. Please operate according to the steps in User Manual or contact us if you have any questions
ASP.NET MVC endpoint for a data URL
The following MVC 5-style action demonstrates the important checks. The 10 MiB limit is an example application policy; choose a value appropriate for your users and enforce a matching request limit in the web server.
using System;
using System.IO;
using System.Web.Mvc;
public class ScreenshotController : Controller
{
[HttpPost]
[Authorize]
[ValidateAntiForgeryToken]
public ActionResult Save(string imageData)
{
const int maxBytes = 10 * 1024 * 1024;
if (String.IsNullOrWhiteSpace(imageData))
return new HttpStatusCodeResult(400, "imageData is required");
const string prefix = "data:image/png;base64,";
if (!imageData.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
return new HttpStatusCodeResult(415, "Only a PNG data URL is accepted");
byte[] bytes;
try
{
bytes = Convert.FromBase64String(imageData.Substring(prefix.Length));
}
catch (FormatException)
{
return new HttpStatusCodeResult(400, "Invalid Base64 data");
}
if (bytes.Length == 0 || bytes.Length > maxBytes)
return new HttpStatusCodeResult(413, "Image is empty or too large");
byte[] pngSignature = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
for (int i = 0; i < pngSignature.Length; i++)
if (bytes[i] != pngSignature[i])
return new HttpStatusCodeResult(415, "PNG signature is missing");
string folder = Server.MapPath("~/App_Data/Screenshots");
Directory.CreateDirectory(folder);
string id = Guid.NewGuid().ToString("N");
string fileName = id + ".png";
string path = Path.Combine(folder, fileName);
System.IO.File.WriteAllBytes(path, bytes);
return Json(new { id = id, url = Url.Action("Get", "Screenshot", new { id = id }) });
}
}
App_Data is not directly served by classic ASP.NET. If you use another storage location, deny script execution and direct directory listing, or write to controlled object storage. Return an identifier or application-generated URL rather than exposing a path supplied by the browser.
Multipart action
For the Blob version, bind an HttpPostedFileBase, require the expected MIME type as an initial check, limit ContentLength, copy the stream to a bounded buffer, verify the same PNG signature, and then use the same generated-name storage routine. Do not rely on the MIME type alone because it is supplied by the client.
html2canvas options that matter
| Option | Use | Important limitation |
|---|---|---|
useCORS: true |
Ask the browser to request images with CORS enabled. | The image host must send an appropriate CORS response header; this option cannot grant permission. |
windowWidth, windowHeight |
Set the virtual viewport used while rendering. | For long elements, matching the element’s scroll dimensions helps avoid clipping, but very large canvases can exceed browser limits. |
scale |
Control output density and memory use. | Higher scale produces more pixels and a larger memory footprint; reduce it when captures become blank or truncated. |
backgroundColor |
Choose a solid background when transparency is not desired. | It changes the rendered canvas background, not the page itself. |
Use toDataURL('image/png') when simplicity matters. Use toBlob() for larger images so the upload is binary multipart data rather than a Base64-expanded form value.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteRank #3
- 【4K HDMI Input, 2K@30Hz Recording】Powered by a true USB 3.0 high-speed interface, the capture card supports up to 4K@30Hz HDMI input and records at 2K@30Hz or 1080P@60Hz. Perfect for gamers, streamers, and professionals who need crisp, smooth video for live streaming, gameplay recording, or online meetings.
- 【Ultra Low Latency Screen Sharing】Built with a premium aluminum alloy shell and advanced chipset for stable heat dissipation, ensuring ultra-low latency transmission. Capture high-quality video and dual-channel audio in real time—no lag, no frame drop—ideal for Twitch, YouTube, or OBS streaming.
- 【Easy Plug and Play, Compact & Portable】No driver or external power required—just plug and play via USB 3.0 or Type-C connection to your Windows or macOS computer. Lightweight and compact design makes it easy to carry for outdoor streaming, live shows, or mobile recording setups.
- 【Wide Compatibility & Multi-Device Support】Compatible with Windows 7 8 10 11, macOS, Linux,Android and supports most popular software such as OBS, Zoom, VLC, Twitch Studio, and more. Works seamlessly with PS4, PS5, Xbox, Switch, DSLR cameras, TV boxes, and other HDMI-output devices for streaming to YouTube, Twitch, etc.
- 【What You Get】Includes: HDMI Capture Card, USB 3.0 to USB-C Adapter, User Manual. Tips: Make sure your tablet’s OTG function is enabled before connecting. Test your HDMI device with a monitor first to confirm video and audio output, then connect to the Video Capture Card for recording.
What this method can and cannot capture
It is a DOM reconstruction
The library reads the DOM, computed styles and browser APIs, then paints supported content onto a canvas. It does not ask the browser for a native compositor screenshot. Unsupported CSS, browser UI, cross-origin pixels, some plugins and content rendered outside the accessible DOM can differ from the visible page.
External images and tainted canvases
An image from another origin can taint the canvas. useCORS succeeds only when that server supplies the required CORS headers. If you control neither origin, use a permitted same-origin proxy that fetches and serves the image with appropriate safeguards. Never create an open proxy: restrict destinations, validate responses and protect it from server-side request forgery.
Large or blank captures
Canvas dimensions vary by browser, operating system, GPU and device. A very long page can therefore be blank, truncated or fail during export. Capture a smaller element, lower scale, split a document into sections, or use a server-side browser when exact full-page rendering is required.
When a server-side browser is the better choice
html2canvas must run where window and document exist; it cannot run in Node.js. For a true server-side screenshot, the html2canvas FAQ points to Puppeteer or Playwright. Compare the approaches before moving work to a server:
Rank #4
- [Enhanced 4K-1080P Video Capture Experience] Capture the Magic: Elevate your video recordings to new heights with our upgraded anti-static 1080P Video Capture Card. Immerse yourself in stunning visuals, supporting HDMI input at 4K 60FPS and USB output for capturing in 1080P, complete with rich stereo sound. Enjoy crystal-clear video recordings, dynamic gaming live streams, and professional conference broadcasts. Note: HDMI resolution: Max input can be 3840×2160@30Hz / Video output resolution: Max output can be 1920×1080@30Hz
- [Seamless Real-Time Preview] Stay in the Moment: Our advanced ultra-low latency technology ensures seamless real-time transmission of video streams. Experience instant, lag-free previews, allowing you to capture every detail precisely. Effortlessly record video directly to your hard disk, all without compromising on quality or introducing any delays.
- [Versatility and Broad Compatibility] Your Creative Hub: Connect your DSLR, camcorder, or action camera to a wide range of operating systems, including Windows, MacOS, and Linux. Unlock a world of possibilities with real-time streaming to popular platforms like Twitch, Youtube, OBS, Zoom, Potplayer, and VLC, giving you the tools to share your content effortlessly.
- [Effortless Plug and Play] Simplicity Redefined: Say goodbye to complex installations. Our plug-and-play design eliminates the need for drivers or external power supplies. Seamlessly integrate high-definition acquisition into various scenarios, whether it's educational recordings, immersive gaming, precise medical imaging, captivating live streams, or professional broadcasting.
- [Seize Every Detail with Precision] Unleash your creativity and attention to detail with our video capture card. Capture every nuance, every color, and every moment with precision, thanks to the enhanced capabilities of our technology. Whether you're a content creator, a gamer, or a professional, our capture card empowers you to seize the finest elements and bring them to life in your recordings and live streams.
| Concern | html2canvas in the user’s browser | Puppeteer or Playwright on a server |
|---|---|---|
| Rendering fidelity | DOM and supported CSS reconstruction; not guaranteed pixel-perfect. | Uses a real automated browser page and is suited to native page screenshots. |
| Cross-origin content | Subject to browser CORS and canvas tainting rules. | Server navigation can be configured for the target site’s network and session requirements. |
| Execution location | Client device. | Your server or worker infrastructure. |
| Authentication and sessions | Uses the visitor’s page and browser cookies. | You must provision credentials, cookies or headers safely. |
| Operations | No browser service to maintain, but every client has different limits. | Requires browser binaries, concurrency controls, timeouts and resource monitoring. |
| Cost profile | Server receives an upload; client CPU and memory do the rendering. | Server pays the CPU, memory and bandwidth cost of each browser job. |
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP or PDF. Before capture it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result.
Use the API when the URL is reachable from a service rather than requiring the current user’s private browser session. The request below captures Stripe and writes the returned WebP:
ScreenshotNeo API documentation
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const bytes = new Uint8Array(await res.arrayBuffer());
ScreenshotNeo also supports full-page captures with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets and custom viewports, retina scale, PDF paper and page-range settings, custom CSS and JavaScript, clicks, selector or network-idle waits, request and resource blocking, custom headers, cookies, user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, caller-selected cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration. An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.
The Free plan includes 1,000 shots each month without a card. Paid plans start at $5 for 3,000 shots; every feature is on every plan, and yearly billing gives two months free. Create a free ScreenshotNeo account to try the API.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesTroubleshooting
The canvas is blank
- Check that the selector returns an element and that the element has dimensions.
- Wait for images and fonts before calling html2canvas.
- Reduce
scaleor capture a shorter region if the canvas is too large. - Inspect the browser console for a tainted-canvas security error caused by an external image.
External images are missing
Confirm that the image response includes the required CORS header and that the image is requested with CORS enabled. If you cannot change the image host, use a tightly restricted same-origin proxy or omit that content.
Best Value
- 【1080P HD High Quality】Capture resolution up to 1080p for video source and it is ideal for all HDMI devices such as PS4, PS3, Xbox One, Xbox 360, Wii U, DVDs, DSLR, Camera, Security Camera and set top box. Note: Video input supports 4K30/60Hz and 1080p120/144Hz. Does not support 4K120Hz/144Hz. Output supports up to 2K30Hz.
- 【Plug and Play】No driver or external power supply required, true PnP. Once plugged in, the device is identified automatically as a webcam. Detect input and adjust output automatically. Won't occupy CPU, optional audio capture. No freeze with correct setting.
- 【Compatible with Multiple Systems】suitable for Windows and Mac OS. High speed USB 3.0 technology and superior low latency technology makes it easier for you to transmit live streaming to Twitch, Youtube, Facebook, Twitter, OBS, Potplayer and VLC.
- 【HDMI LOOP-OUT】Based on the high-speed USB 3.0 technology, it can capture one single channel HD HDMI video signal. There is no delay when you are playing game live.
- 【Support Mic-in for Commentary】Rybozen capture card has microphone input and you can use it to add external commentary when playing a game. Please note: it only accepts 3.5mm TRS standard microphone headset.
The POST returns 400, 413 or 415
- 400: the field is empty or the Base64 text is malformed; verify the data URL prefix and decoding.
- 413: the application or web server request limit is smaller than the screenshot; reduce dimensions or raise the limit deliberately.
- 415: the endpoint rejected a non-PNG MIME prefix or signature; ensure the client exports PNG and that no transformation changed the bytes.
The request is 403
Authentication or anti-forgery validation failed. Send the user’s authenticated cookie and the token in the format expected by your ASP.NET configuration; do not remove authorization merely to make uploads work.
The file exists but cannot be opened
Make sure the server decoded only the Base64 portion, wrote all bytes, and generated the extension from the validated format. Check storage permissions and confirm that the response is not an HTML error page saved with a .png name.
Performance, reliability and operational safeguards
- Capture only the required element instead of the entire document whenever possible.
- Prefer Blob uploads for large images and set explicit client and server timeouts.
- Apply authentication, CSRF protection, rate limits and per-user quotas to the endpoint.
- Keep files outside executable web directories, scan or validate content as appropriate, and store metadata (owner, dimensions, creation time and retention deadline) separately.
- Use generated opaque IDs, not user filenames, and prevent path traversal.
- Delete expired screenshots and return a controlled download action that checks authorization on every request.
- For repeated public URLs, a screenshot API’s cache and asynchronous jobs can reduce repeated browser work; inspect its verdict and billing headers before treating a result as successful.
Frequently Asked Questions
How can I return a download instead of a JSON URL?
Keep the generated ID in your database and expose an authorized action that streams the stored bytes with a fixed image/png content type and an attachment filename derived from the server-side ID.
Should screenshots be stored permanently?
Usually not. Define a retention period for the feature, record its deadline with the screenshot metadata, and run a scheduled deletion job that checks ownership before removing each object.
Can two users safely upload a file called capture.png?
Yes, if the server ignores that client name and uses a cryptographically unpredictable or GUID-based identifier. The original name can be retained only as display metadata after validation.
Quick Recap
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.




