【发布时间】:2021-09-06 20:25:43
【问题描述】:
我创建了一个 Blazor 解决方案,它有一个 .client 项目和一个 .server 项目。
当我选择客户端作为启动时,它无法读取我在 .server 上的 api,当我选择 .server 作为启动时,它不会命中在我的 .client 中设置的断点。
我已尝试使用多启动项目设置,但它仍然无法读取服务器 API。
这是服务器应用程序中的启动设置,如果我在那里有检查 url,应用程序将无法启动并出现此错误
"SeekaPortal.Server": {
"commandName": "Project",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
这是startup.cs
public void ConfigureServices(IServiceCollection services) {
services.AddMvc(options =>
{
options.EnableEndpointRouting = false;
});
services.AddDbContext<SeekaportalContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("PortalConnection")));
services.AddControllersWithViews();
services.AddRazorPages();
services.AddAuthentication();
services.ConfigureIdentity();
services.ConfigureJwt(Configuration);
services.ConfigureServices();
services.AddControllers();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseBlazorFrameworkFiles();
app.UseStaticFiles();
app.UseWebAssemblyDebugging();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
endpoints.MapControllers();
endpoints.MapFallbackToFile("index.html");
});
}
如何让客户端读取服务器或在服务器启动时触发客户端应用程序上的断点?
非常感谢
【问题讨论】:
-
只有在您的应用程序被托管时才必须启动服务器(创建应用程序时的 ASP.NET 托管复选框)。分享您的客户端在调试时不会停止的源代码。
-
是的,它是 asp.net 托管的
-
您必须将服务器设置为启动项目。它托管客户端,您也可以对其进行调试。如果您将客户端设置为启动项目,它将启动但不会启动服务器。如果单独启动服务器,安全性将不起作用。
-
是的,我遇到的问题是它不允许我调试客户端。每个断点只是说“断点当前不会被命中。未绑定断点”
-
请分享您的代码
标签: blazor blazor-server-side blazor-webassembly