
Blazor WebAssembly on .Net 5
After updating Telerik.UI.For.Blazor to version 2.23.0 I often see an error in the Console "Could not find 'TelerikBlazor.getLocationHost' ('TelerikBlazor' was undefined)." after doing a build and refreshing the page. If I then refresh the page again the error will not reappear.
I am only using the TelerikGrid.
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Could not find 'TelerikBlazor.getLocationHost' ('TelerikBlazor' was undefined).
Error: Could not find 'TelerikBlazor.getLocationHost' ('TelerikBlazor' was undefined).
at https://localhost:44359/_framework/blazor.webassembly.js:1:1287
at Array.forEach (<anonymous>)
at e.findFunction (https://localhost:44359/_framework/blazor.webassembly.js:1:1247)
at b (https://localhost:44359/_framework/blazor.webassembly.js:1:2989)
at https://localhost:44359/_framework/blazor.webassembly.js:1:3935
at new Promise (<anonymous>)
at Object.beginInvokeJSFromDotNet (https://localhost:44359/_framework/blazor.webassembly.js:1:3908)
at Object.w [as invokeJSFromDotNet] (https://localhost:44359/_framework/blazor.webassembly.js:1:64232)
at _mono_wasm_invoke_js_blazor (https://localhost:44359/_framework/dotnet.5.0.4.js:1:190800)
at do_icall (<anonymous>:wasm-function[10596]:0x194e4e)
Microsoft.JSInterop.JSException: Could not find 'TelerikBlazor.getLocationHost' ('TelerikBlazor' was undefined).
Error: Could not find 'TelerikBlazor.getLocationHost' ('TelerikBlazor' was undefined).
at https://localhost:44359/_framework/blazor.webassembly.js:1:1287
at Array.forEach (<anonymous>)
at e.findFunction (https://localhost:44359/_framework/blazor.webassembly.js:1:1247)
at b (https://localhost:44359/_framework/blazor.webassembly.js:1:2989)
at https://localhost:44359/_framework/blazor.webassembly.js:1:3935
at new Promise (<anonymous>)
at Object.beginInvokeJSFromDotNet (https://localhost:44359/_framework/blazor.webassembly.js:1:3908)
at Object.w [as invokeJSFromDotNet] (https://localhost:44359/_framework/blazor.webassembly.js:1:64232)
at _mono_wasm_invoke_js_blazor (https://localhost:44359/_framework/dotnet.5.0.4.js:1:190800)
at do_icall (<anonymous>:wasm-function[10596]:0x194e4e)
at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__15`1[[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at Telerik.Blazor.Components.Dialog.DialogBuilder.OnAfterRenderAsync(Boolean firstRender)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
8 Answers, 1 is accepted
Hi Wayne,
Please try the steps from this article: https://docs.telerik.com/blazor-ui/troubleshooting/js-errors
Regards,
Marin Bratanov
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi Giuseppe,
As long as the <script> declaration has no defer attribute, it should be a blocking script and force the browser to load the file before parsing the rest of the DOM. So, I don't expect the asp-append-version attribute to cause problems.
Are you saying that you get a JavaScript error only when you have the asp-append-version="true" attribute to our JS file? Does the error occur only once after you clear the browser cache? Or does it always occur the first time the app is opened in the browser?
Can you show us where exactly the JavaScript file is registered in the page markup? Also, what do you observe in the browser's Network tab when the error occurs - is the file not loaded at all, or is it loaded for too long?

I'm getting the same error after upgrading, also on .Net 5. The provided troubleshooting link didn't help.
I downgraded back to 2.22 and the error is gone.
Any info on how to solve this specific error?
Unhandled exception rendering component: Could not find 'TelerikBlazor.getLocationHost' ('TelerikBlazor' was undefined).
Thanks.
Hi Yoly,
This is definitely a wrong JS Interop file being used in the browser.
Clearing the browser cache should help.
If it is a build issue with the build caching old assets, deleting the bin and obj folders will help (then clear the browser cache too).
If you are not using the static assets but the cdn, make sure to update its URL too to point to the new package version as well.
If neither of this helps, please open a support ticket with the sample project that has the problem.
Regards,
Marin Bratanov
Progress Telerik
Тhe web is about to get a bit better!
The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Hi Marin,
It seems it was a browser cache issue. I had previously done clean/rebuild and it didn't help, clearing the browser cache as you suggested fixed the issue.
Thanks for the help!


Well It ended up that I still had the defer, This project was copied from a base project and I forgot to remove it in this one (I have multiple projects using Telerik in Blazor). I will try it without the defer and see how it goes.

var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseStaticWebAssets(); // ----> added this line here
var app = builder.Build();
app.UseStaticFiles(); // ---> Make sure this line exists

I got a similar error.
In my case, I began using the Trial, then got a License, but did not change the JavaScript and CSS accordingly.
So I changed from the Trial:
<script src="_content/Telerik.UI.for.Blazor.Trial/js/telerik-blazor.js" defer></script>
<link rel="stylesheet" href="_content/Telerik.UI.for.Blazor.Trial/css/kendo-theme-default/all.css" />
To the Licensed version:
<script src="_content/Telerik.UI.for.Blazor/js/telerik-blazor.js" defer></script>
<link rel="stylesheet" href="_content/Telerik.UI.for.Blazor/css/kendo-theme-default/all.css" />
Hope that helps someone who get this error.