dotnet/runtime · error · Error
URLSearchParams is supported
Error message
URLSearchParams is supported
What it means
Thrown by withApplicationArgumentsFromQuery() when globalThis.URLSearchParams is undefined. The message text is misleading ('URLSearchParams is supported') — the intent is the opposite: URLSearchParams is NOT supported in this environment. Treat it as a feature-detection failure. URLSearchParams is available in all modern browsers and Node 10+, so this fires only in very old runtimes or stripped shells.
Solutions
- Add a URLSearchParams polyfill (core-js or url-search-params-polyfill) before bootstrapping.
- Upgrade the host runtime to a version with native URLSearchParams.
- Skip withApplicationArgumentsFromQuery and pass args via withApplicationArguments.
- If you control the host, register globalThis.URLSearchParams from your runtime.
Example fix
// before builder.withApplicationArgumentsFromQuery(); // throws on old WebView // after import 'url-search-params-polyfill'; builder.withApplicationArgumentsFromQuery();
Defensive patterns
Strategy: type-guard
Validate before calling
function hasURLSearchParams(): boolean {
return typeof (globalThis as any).URLSearchParams === 'function';
} Type guard
function supportsUrlSearchParams(): boolean {
return typeof (globalThis as any).URLSearchParams === 'function';
} Try / catch
try { builder.withApplicationArgumentsFromQuery(); } catch (e) {
if (/URLSearchParams/.test((e as Error).message)) {
// polyfill or pass args explicitly
builder.withApplicationArguments(/* args */);
} else throw e;
} Prevention
- Bundle a URLSearchParams polyfill (core-js) when targeting old WebView/IE-class runtimes.
- Feature-detect before calling withApplicationArgumentsFromQuery.
- Document a minimum-browser support matrix for your app.
- Note the misleading message — the runtime means URLSearchParams is NOT supported.
When it happens
Trigger: Running in an ancient embedded JS engine (old WebView, legacy Edge, IE11 polyfill missing). A shell/host that intentionally removed URLSearchParams. Node older than 10 (unsupported). Some smart-TV/legacy mobile webviews.
Common situations: Polyfilled environment where the URLSearchParams polyfill was not loaded. Old WebView on Android <5. Custom JS host (V8 isolate) without the URL API.
Related errors
- This browser doesn't support fetch API. Please use a modern…
- This browser doesn't support fetch API. Please use a modern…
- Missing window to the query parameters from
- Missing window to the query parameters from
- No fetch implementation available
AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10).
Data as JSON: /api/errors/fda1b493d7abdbea.
Report an issue: GitHub.
Appendix: source
Thrown at src/native/libs/Common/JavaScript/loader/host-builder.ts:75
withDebugging(level: number): DotnetHostBuilder {
mergeLoaderConfig({
debugLevel: level
});
return this;
}
withMainAssembly(mainAssemblyName: string): DotnetHostBuilder {
mergeLoaderConfig({
mainAssemblyName: mainAssemblyName
});
return this;
}
withApplicationArgumentsFromQuery(): DotnetHostBuilder {
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);
}
withApplicationEnvironment(applicationEnvironment?: string): DotnetHostBuilder {
mergeLoaderConfig({
applicationEnvironment: applicationEnvironment
});
return this;
}
withApplicationCulture(applicationCulture?: string): DotnetHostBuilder {
mergeLoaderConfig({
applicationCulture: applicationCulture
});
return this;
}View on GitHub (pinned to 60108ba66e)