dotnet/runtime · error · Error

URLSearchParams is supported

Error message

URLSearchParams is supported

What it means

Thrown by HostBuilder.withApplicationArgumentsFromQuery when globalThis.URLSearchParams is undefined. NOTE: the message text ('URLSearchParams is supported') is misleading — it actually indicates URLSearchParams is NOT available in the host. It guards the subsequent use of `new URLSearchParams(window.location.search)`.

Source

Thrown at src/mono/browser/runtime/loader/run.ts:182

        try {
            deep_merge_config(monoConfig, {
                mainAssemblyName
            });
            return this;
        } catch (err) {
            mono_exit(1, err);
            throw err;
        }
    }

    withApplicationArgumentsFromQuery (): DotnetHostBuilder {
        try {
            if (!globalThis.window) {
                throw new Error("Missing window to the query parameters from");
            }

            if (typeof globalThis.URLSearchParams == "undefined") {
                throw new Error("URLSearchParams is supported");
            }

            const params = new URLSearchParams(globalThis.window.location.search);
            const values = params.getAll("arg");
            return this.withApplicationArguments(...values);
        } catch (err) {
            mono_exit(1, err);
            throw err;
        }
    }

    withApplicationEnvironment (applicationEnvironment?: string): DotnetHostBuilder {
        try {
            deep_merge_config(monoConfig, {
                applicationEnvironment,
            });
            return this;
        } catch (err) {

View on GitHub (pinned to 290d5ab72c)

Solutions

  1. Upgrade to a modern browser/WebView that provides URLSearchParams.
  2. Polyfill URLSearchParams on globalThis before booting (e.g. the 'url-search-params' polyfill).
  3. Avoid withApplicationArgumentsFromQuery in such environments; use withApplicationArguments(...) with values parsed by your own code.

Example fix

// before: legacy browser lacking URLSearchParams
// builder.withApplicationArgumentsFromQuery(); // throws

// after: polyfill first, or pass args directly
import 'url-search-params-polyfill';
builder.withApplicationArgumentsFromQuery();
// or:
builder.withApplicationArguments(...myParsedArgs);
Defensive patterns

Strategy: validation

Validate before calling

if (typeof globalThis.URLSearchParams === 'undefined') {
  // polyfill or avoid withApplicationArgumentsFromQuery
}

Type guard

function hasURLSearchParams(): boolean {
  return typeof globalThis !== 'undefined' && typeof globalThis.URLSearchParams !== 'undefined';
}

Prevention

When it happens

Trigger: Produced when withApplicationArgumentsFromQuery runs (window exists) but globalThis.URLSearchParams is undefined — a very old browser/engine lacking the URLSearchParams constructor.

Common situations: Running in an extremely old browser or legacy WebView that predates URLSearchParams; a polyfill gap in a custom host.

Related errors


AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06). Data as JSON: /api/errors/94eb8775da7ea828. Report an issue: GitHub.