Skip to content

Commit f6261dc

Browse files
committed
Sync with Kendo UI Professional
1 parent c80c90b commit f6261dc

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

docs-aspnet/_config-mvc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ asp-net-mvc-3.md,
3333
asp-net-mvc-4.md,
3434
troubleshoot/troubleshooting-net8.md,
3535
knowledge-base/checkbox-list-post.md,
36+
knowledge-base/csp-browserlink.md,
3637
knowledge-base/daterangepicker-bind-to-model-and-post.md,
3738
knowledge-base/daterangepicker-messages-input-text-change.md,
3839
knowledge-base/docker-build-nuget.md,
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: Resolve Hot Reload BrowserLink error with enabled CSP
3+
description: Explanation and solution for the browserLink javascript error when enabling CSP and running a project from Microsoft Visual Studio.
4+
type: troubleshooting
5+
page_title: Resolve Hot Reload BrowserLink error with enabled CSP
6+
slug: csp-browserlink
7+
tags: csp, error, browserlink, hot, reload
8+
res_type: kb
9+
---
10+
11+
## Environment
12+
13+
<table>
14+
<tr>
15+
<td>Product</td>
16+
<td>Telerik® UI for ASP.NET Core</td>
17+
</tr>
18+
</table>
19+
20+
21+
## Description
22+
23+
New versions of Microsoft Visual Studio provide the [Hot Reload](https://learn.microsoft.com/en-us/aspnet/core/test/hot-reload?view=aspnetcore-9.0) and [Browser Link Refresh](https://learn.microsoft.com/en-us/aspnet/core/client-side/using-browserlink?view=aspnetcore-9.0) features in order to facilitiate working with ASP.NET Core projects.
24+
25+
This creates a communication channel between the development environment and one or more web browsers. And since this communication is done with a javascript file connection, when you implement the Content Security Policy meta tag for your application you can see these errors:
26+
27+
```js
28+
browserLink:4 Refused to connect to 'http://localhost:.../8d05de7…/browserLinkSignalR/…owserLink.initializationData.browserId&browserId=...' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.
29+
send @ browserLink:4
30+
31+
browserLink:4 Refused to connect to 'http://localhost:.../8d05de7…/browserLinkSignalR/…owserLink.initializationData.browserId&browserId=...' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.
32+
send @ browserLink:4
33+
34+
aspnetcore-browser-refresh.js:329 Refused to connect to 'wss://localhost:.../TelerikProjectName/' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.
35+
(anonymous) @ aspnetcore-browser-refresh.js:329
36+
```
37+
38+
## Solution
39+
40+
To resolve this issue you can add `connect-src ws: http: 'self';` to your CSP meta tag in the `_Layout.cshtml` file:
41+
42+
```html
43+
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src 'self' data:; script-src 'self' https://kendo.cdn.telerik.com https://code.jquery.com/ https://cdn.kendostatic.com https://unpkg.com 'nonce-Telerik-Examples'; style-src 'self' https://kendo.cdn.telerik.com https://unpkg.com; font-src 'self' https://unpkg.com; connect-src ws: http: 'self';" />
44+
```
45+
46+
## See Also
47+
48+
* [Content Security Policy Documentation](https://docs.telerik.com/aspnet-core/html-helpers/helper-basics/content-security-policy)
49+
* [Telerik UI for Core CSP Example](https://github.com/telerik/ui-for-aspnet-core-examples/tree/master/Telerik.Examples.ContentSecurityPolicy)

0 commit comments

Comments
 (0)