gpt4 book ai didi

blazor - 带有 Blazor 应用程序的随机 "Error: The circuit failed to initialize"

转载 作者:行者123 更新时间:2023-12-05 06:21:29 25 4
gpt4 key购买 nike

我目前正在开发 Blazor 服务器端应用程序,但在启动页面后直接遇到随机错误。当我按下 F5 按钮或单击我的索引页面上的任何链接时,页面会重新加载并且错误不会再次出现。错误消息非常笼统,我真的不知道从哪里开始调试它。即使我完全删除作为起始页的 Index.razor 页面的内容,也会发生错误。任何想法如何解决这个问题?我在 IISExpress 下的本地计算机上运行它。

blazor.server.js:1 [2020-01-22T08:08:24.333Z] Information: Normalizing '_blazor' to 'https://localhost:44347/UserManagement/_blazor'.
blazor.server.js:1 [2020-01-22T08:08:24.845Z] Information: WebSocket connected to wss://localhost:44347/UserManagement/_blazor?id=SDcEnRoqVlu-3GRhPqRj7g.
blazor.server.js:15 [2020-01-22T08:08:25.064Z] Error: The circuit failed to initialize.
e.log @ blazor.server.js:15
C @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:1
e.invokeClientMethod @ blazor.server.js:1
e.processIncomingData @ blazor.server.js:1
connection.onreceive @ blazor.server.js:1
i.onmessage @ blazor.server.js:1
blazor.server.js:1 [2020-01-22T08:08:25.067Z] Information: Connection disconnected.
blazor.server.js:1 Uncaught (in promise) Error: Invocation canceled due to the underlying connection being closed.
at e.connectionClosed (blazor.server.js:1)
at e.connection.onclose (blazor.server.js:1)
at e.stopConnection (blazor.server.js:1)
at e.transport.onclose (blazor.server.js:1)
at e.close (blazor.server.js:1)
at e.stop (blazor.server.js:1)
at e.<anonymous> (blazor.server.js:1)
at blazor.server.js:1
at Object.next (blazor.server.js:1)
at a (blazor.server.js:1)
e.connectionClosed @ blazor.server.js:1
connection.onclose @ blazor.server.js:1
e.stopConnection @ blazor.server.js:1
transport.onclose @ blazor.server.js:1
e.close @ blazor.server.js:1
e.stop @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
a @ blazor.server.js:1
Promise.then (async)
c @ blazor.server.js:8
a @ blazor.server.js:8
Promise.then (async)
c @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
r @ blazor.server.js:8
E @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
n @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1

我的 Startup.cs 看起来像这样:

    using Blazored.Modal;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using UserManagement.Data;
using UserManagement.Models;

namespace UserManagement
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
services.AddServerSideBlazor().AddCircuitOptions(options => { options.DetailedErrors = true; });
services.AddBlazoredModal();
services.AddDbContext<UserManagementContext>(options => options.UseSqlServer(REMOVED);
services.AddDbContext<RecertificationContext>(options => options.UseSqlServer(REMOVED);

var config = new ConfigurationBuilder()
.Build();
services.AddSingleton(config);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UsePathBase("/UserManagement");
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseEndpoints(endpoints =>
{
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
});
}


}
}

_Host.cshtml

@page "/"
@namespace UserManagement.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>UserManagement</title>
<environment include="Development">
<base href="/UserManagement/" />
</environment>
<environment exclude="Development">
<base href="~/" />
</environment>
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<link href="_content/Blazored.Typeahead/blazored-typeahead.css" rel="stylesheet" />
<link href="_content/Blazored.Modal/blazored-modal.css" rel="stylesheet" />
</head>
<body>
<app>
@(await Html.RenderComponentAsync<App>(RenderMode.ServerPrerendered))
</app>

<script src="_framework/blazor.server.js"></script>
<script src="_content/Blazored.Typeahead/blazored-typeahead.js"></script>
<script src="_content/BlazorFileSaver/BlazorFileSaver.min.js"></script>
</body>
</html>

最佳答案

这很有趣。我创建了一个新的 Blazor 服务器端项目并将我的所有类复制到该项目并确保两个项目中的代码相同。你猜怎么着,这个错误并没有出现在新项目中。

有什么方法可以“删除”某种超出清理/重建项目范围的缓存吗?

关于blazor - 带有 Blazor 应用程序的随机 "Error: The circuit failed to initialize",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59837098/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com