General Issues
This page provides solutions for common issues you may encounter while working with Telerik UI for Blazor components.
- TelerikRootComponent is missing
- Popups do not work
- Wrong popup position
- Unable to find package Telerik.Documents.SpreadsheetStreaming
- Cannot provide a value for property 'Localizer'
- Slow Performance
- Failed to find a valid digest in the 'integrity' attribute for resource ... with computed SHA-256 integrity ...
- JavaScript errors
- Issues after deployment
- Content Security Policy
- NuGet feed troubleshooting
- Upload troubleshooting
Popups Do Not Work
There are three common reasons for this
- Missing
<TelerikRootComponent>
from the app. - Missing
telerik-blazor.js
file - Special positioning on the
<app>
element or any other parent of theTelerikRootComponent
.
The <app>
element is the topmost component that a developer can access in Blazor. This means that we cannot place our popups higher than that in the DOM. Thus, their position and visibility depend on the position of the <app>
element matching the position of the <body>
element.
The default application template has a position: relative
rule for the app
element that can break the appearance and positions of our popups (most notably in Firefox). The solution is to remove such special positioning. For example, modify the default site.css
file like this:
app {
/* remove this line */
/* position: relative; */
/*
if you continue experiencing issues, try removing these lines as well
make sure that the app element positioning matches the body element and is visible
*/
display: flex;
flex-direction: column;
}
Wrong Popup Position
The position of popups (Dialog, Notification, Window) and dropdowns (ComboBox, DatePicker, DropDownList, SplitButton) can be wrong or offset.
The possible reasons and remedies for this problem are:
- The
<TelerikRootComponent>
does not wrap all the visible HTML content on the web page. As a result, the Telerik popups and dropdowns do not render at the root of the app and their position is affected by other styles and parent HTML elements on the page. Normally, the<TelerikRootComponent>
must be the topmost component in the topmost layout of the app, except in apps with Per Page/Component interactivity location. - There is more than one rendered
<TelerikRootComponent>
in the app. Remove the inner one, which most likely does not wrap all the content on the page. - The
<body>
HTML element has non-zeromargin
styles. This breaks the position calculations for the Telerik popups and dropdowns. Even if amargin
style is set on a child element, it may propagate up the DOM to the<body>
due to CSS margin collapse. In such cases, you can replacemargin
styles withpadding
styles. - A parent HTML element of the
<TelerikRootComponent>
has non-default positioning styles, for exampleposition:relative
,top:20px
, orleft:100px
. Such styles offset all children, including the Telerik popups and dropdowns. Move such positioning styles to another element inside theTelerikRootComponent
.
The <TelerikRootComponent>
itself does not render any HTML elements. For troubleshooting purposes, you can assess the placement of the root component by the placement of the currently visible Telerik popups and dropdowns. See how to inspect auto-hiding popups in the browser.
Unable to find package Telerik.Documents.SpreadsheetStreaming
When attempting to restore packages or build a solution with the Telerik.UI.for.Blazor
NuGet package, you may get an error similar to
Unable to find package Telerik.Documents.SpreadsheetStreaming. No packages exist with this id in source(s) Microsoft Visual Studio Offline Packages, nuget.org, Telerik, MyOfflinePackages
The Telerik.Documents.SpreadsheetStreaming
package is used internally for exporting and the main package references it. It is also available from our online feed and it is in the dpl
folder of your offline installation.
The most common reasons and solutions for seeing this error (being unable to restore this particular package) are:
-
An offline package source is being used that does not contain it. Make sure that you add the packages from both the
packages
anddpl
folders to such a custom local feed. -
There is an issue with connecting to our online feed. For example, a firewall, network downtime or wrong credentials are used. Check the Troubleshooting NuGet Feed Issues section of the documentation to see how to handle that.
-
There is a mismatch between the versions available for restore and the referenced versions, while the Visual Studio "treat warnings as errors" setting is turned on. This can happen if one version is referenced, but another is available (for example, only certain versions are available in a custom local feed for the Document Processing packages, but the main package references an older version). In such cases, the tooling would usually resolve the newest version, but it will show a warning and VS can treat it as an error and not let you build. The solution is to check the version that is referenced by
Telerik.UI.for.Blazor
and ensure you can access that. Cleaning the solution, manually restoring the packages and re-building can also help.
Cannot provide a value for property 'Localizer'
If you get an error similar to this one:
InvalidOperationException: Cannot provide a value for property 'Localizer' on type 'Telerik.Blazor.Components.TelerikMenu[[TelerikBlazorApp1.Models.MenuItem, TelerikBlazorApp1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'. There is no registered service of type 'Telerik.Blazor.Services.ITelerikStringLocalizer'.
There can be two common causes for the problem:
-
The Telerik services are not registered in the app, a line similar to
builder.Services.AddTelerikBlazor();
is missing. -
The application uses localization, or there is a code snippet that does (e.g., a grid with custom buttons that are localized, copied over from another place), but the current app does not provide the necessary project-specific service. You can read more about implementing one in the Localization article.
Slow Performance
When building a Blazor app, especially on the WebAssembly flavor, it is likely that the first time you have a large set of data and complex interactions will be when you add a Telerik Grid to your project. So, it may seem like a slowdown comes from the grid, but this is not necessarily the case, and there are several important factors into play:
-
Whether you build the WebAssembly app in
Debug
orRelease
mode makes a significant difference in its performance. To see what you users will see, build your app inRelease
mode. It defaults toDebug
while you are developing it. -
Follow Microsoft's best practices to optimize the Blazor WebAssembly general performance. WebAssembly is still considerably slower than server-side Blazor, and Microsoft are working on that.
- The first big improvement that should come from the framework is AOT Compilation (ahead-of-time compilation), and when it becomes available the grid should benefit from it immediately. Another feature that can improve performance is actual multithreading.
-
The performance of the Telerik components is quite close to plain HTML elements rendering, especially considering all the additional features, events and beautiful rendering they add.
There are also certain measures a web app should take to improve its performance in general. For example:
-
Enable Paging or Virtual Scrolling in the grid, and use a reasonable page size (for example, 10 to 20 or 40, as more than 20 items can rarely fit on a screen anyway). Also, if you have many columns, enable Column Virtualization.
-
Avoid loading all the data at once, only load and render relevant chunks. For example, use the OnRead event of the Grid for the grid to perform all operations, and use custom filtering in the ComboBox through its own OnRead event. This also applies to creating lists of a lot of components in your own
foreach
loops - consider implementing your own virtual scrolling or use the Telerik Pager to help you separate them into smaller sets. -
When using a series of your own components on the page, consider overriding their
ShouldRender
methods so they render only when needed. For example, anEventCallback
whose handler is anasync Task
will render its own component, its parent and siblings twice, and you can reduce that to once. -
Loading content on demand (such as a cell value) should be done through a nested component and its
OnParemetersSetAsync
method. A similar example is available in the load tooltip content on demand and load hierarchy data on demand sample projects. You should not use an async method in a component'sTemplate
(or anyRenderFragment
) directly, because their execution is awaited by the framework before the fragment can render at all (Templates
andRenderFragment
instances are basically synchronous). -
If you need to generate documents or prepare some data, try to offload this task to the server. You can create an HTTP request and gather the processed information. With this approach, you will gain from the better server-side performance and won't download all the data on the client-side. You can find an example of the approach in the Export Grid to PDF on the Server sample project.
Failed to find a valid digest in the 'integrity' attribute for resource ... with computed SHA-256 integrity ...
The error is a general Blazor WebAssembly issue, which can result from the build process, publishing process, or browser cache. Our knowledge base article about the Failed to find a valid digest in the 'integrity' attribute
exception contains discussions and documentation with possible solutions.