{"record":{"id":"fda1b493d7abdbea","repo":"dotnet/runtime","slug":"urlsearchparams-is-supported-fda1b4","errorCode":null,"errorMessage":"URLSearchParams is supported","messagePattern":"URLSearchParams is supported","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/native/libs/Common/JavaScript/loader/host-builder.ts","lineNumber":75,"sourceCode":"    withDebugging(level: number): DotnetHostBuilder {\n        mergeLoaderConfig({\n            debugLevel: level\n        });\n        return this;\n    }\n    withMainAssembly(mainAssemblyName: string): DotnetHostBuilder {\n        mergeLoaderConfig({\n            mainAssemblyName: mainAssemblyName\n        });\n        return this;\n    }\n    withApplicationArgumentsFromQuery(): DotnetHostBuilder {\n        if (!globalThis.window) {\n            throw new Error(\"Missing window to the query parameters from\");\n        }\n\n        if (typeof globalThis.URLSearchParams === \"undefined\") {\n            throw new Error(\"URLSearchParams is supported\");\n        }\n\n        const params = new URLSearchParams(globalThis.window.location.search);\n        const values = params.getAll(\"arg\");\n        return this.withApplicationArguments(...values);\n    }\n    withApplicationEnvironment(applicationEnvironment?: string): DotnetHostBuilder {\n        mergeLoaderConfig({\n            applicationEnvironment: applicationEnvironment\n        });\n        return this;\n    }\n    withApplicationCulture(applicationCulture?: string): DotnetHostBuilder {\n        mergeLoaderConfig({\n            applicationCulture: applicationCulture\n        });\n        return this;\n    }","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/native/libs/Common/JavaScript/loader/host-builder.ts#L57-L93","documentation":"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.","triggerScenarios":"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.","commonSituations":"Polyfilled environment where the URLSearchParams polyfill was not loaded. Old WebView on Android <5. Custom JS host (V8 isolate) without the URL API.","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."],"exampleFix":"// before\nbuilder.withApplicationArgumentsFromQuery(); // throws on old WebView\n\n// after\nimport 'url-search-params-polyfill';\nbuilder.withApplicationArgumentsFromQuery();","handlingStrategy":"type-guard","validationCode":"function hasURLSearchParams(): boolean {\n  return typeof (globalThis as any).URLSearchParams === 'function';\n}","typeGuard":"function supportsUrlSearchParams(): boolean {\n  return typeof (globalThis as any).URLSearchParams === 'function';\n}","tryCatchPattern":"try { builder.withApplicationArgumentsFromQuery(); } catch (e) {\n  if (/URLSearchParams/.test((e as Error).message)) {\n    // polyfill or pass args explicitly\n    builder.withApplicationArguments(/* args */);\n  } else throw e;\n}","preventionTips":["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."],"tags":["environment","browser","polyfill","compatibility"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}