找不到blazor.server.js文件 [英] blazor.server.js file not found

查看:528
本文介绍了找不到blazor.server.js文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的ASP.NET Core 3.0 Web应用程序,并选择了Model-View-Controller选项.我想添加Blazor服务器端,因此将以下内容添加到Startup.cs文件中.

I created a new ASP.NET Core 3.0 Web application and selected the Model-View-Controller option. I wanted to add Blazor Server side, so I added the below to the Startup.cs file.

services.AddServerSideBlazor(); 
endpoints.MapBlazorHub();

并添加了脚本文件

<script src="_framework/blazor.server.js"></script>

在我的布局文件中.

我创建了一个简单的组件来显示我在文本框中输入的内容,并将该组件添加到我的Index.cshtml视图中.它可以在Visual Studio中运行,但是当我将其推送到我的内部2016服务器时,会呈现该组件,但不会显示文本.该应用似乎找不到blazor.server.js文件.

I created a simple component that displays what I enter in a textbox, and added the component to my Index.cshtml view. It works within Visual Studio, but when I push it up to my internal 2016 server, the component is rendered but the text is not displayed. The app can't seem to find the blazor.server.js file.

我是否缺少其他一些部署步骤来提升JS文件?

Is there some other deployment step I am missing to push up the JS file?

推荐答案

就我而言,

app.UseStaticFiles(new StaticFileOptions
{
    ServeUnknownFileTypes = true,
    DefaultContentType = "application/octet-stream"
});

是导致问题的原因.替换为:

is what caused the issue. Replace it with:

app.UseStaticFiles();

解决了问题.我发现问题可能出在DefaultContentType上.

solved the problem. I figured maybe DefaultContentType is where the problem is.

任何人都知道为什么会发生这种情况,请更新此答案.

Anyone knows better why that is the case please update this answer.

这篇关于找不到blazor.server.js文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆