【发布时间】:2021-08-15 09:15:05
【问题描述】:
我正在处理.net 5 blazor wasm 项目。我最近将我的Visual Studio 2019 更新为版本16.10.0。突然间,我开始在我的浏览器(谷歌浏览器)console 中收到一条错误消息,如下所示:
拒绝加载脚本 'https://localhost:44340/_framework/aspnetcore-browser-refresh.js' 因为它违反了以下内容安全政策指令: “脚本-src 'sha256-fa5rxHhZ799izGRP38+h4ud5QXNT0SFaFlh4eqDumBI='”。 请注意,'script-src-elem' 没有明确设置,所以 'script-src' 是 用作后备。
我的index.html 中没有添加_framework/aspnetcore-browser-refresh.js。这是我index.html中的脚本和样式声明
styles 在<head> 中声明在index.html:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>App</title>
<base href="/" />
<link href="css/site.css" rel="stylesheet" />
<link href="Web.styles.css" rel="stylesheet">
<link href="_content/BlazorDateRangePicker/daterangepicker.min.css" rel="stylesheet" />
<link href="manifest.json" rel="manifest" />
<link rel="apple-touch-icon" sizes="512x512" href="icon-512.png" />
</head>
scripts in index.html:
<script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"></script>
<script src="_framework/blazor.webassembly.js"></script>
<script src="js/Chart.js"></script>
<script src="js/print.js"></script>
<script src="js/pdf.js"></script>
<script src="_content/BlazorDateRangePicker/clickAndPositionHandler.js"></script>
<script src="js/blazorInterop.js"></script>
<script>navigator.serviceWorker.register('service-worker.js');</script>
但是当我通过visual studio 启动应用程序时,我可以从浏览器中看到_framework/aspnetcore-browser-refresh.js 被附加到我的index.html 的脚本部分。这是屏幕打印。
这与我的配置错误有关吗?或者我需要在我的index.html 中设置 CSP?请帮忙。
【问题讨论】:
标签: asp.net-core visual-studio-2019 blazor content-security-policy blazor-webassembly