本文介绍了如何在使用区域的剃须刀组件库中使用blazor服务器端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的 .net core 3.0预览7 Web应用程序.我的应用程序主要是剃刀页,它们被组织成区域,例如.管理员,销售人员等.如果将 blazor 组件放置在应用程序的根目录中,则可以成功使用它,但是,如果将组件移至RCL,则可以访问该组件,但可以没有响应(单击计数器示例的按钮不会增加计数).

I have an existing .net core 3.0 preview 7 web application. My application is mainly razor-pages organized into areas eg. Admin, Sales, etc. I am able to successfully use a blazor component if I put it at the root of the application, however, if I move the component to an RCL I can access the component but it is not responsive (clicking the button for the counter example does not increment the count).

我希望能够进入 localhost/Admin/RazorPageContainingBlazorComponent localhost/Sales/AnotherRazorPageContainingBlazorComponent

我在chrome开发工具中遇到此错误:'''错误:无法完成与服务器的协商:错误

I get this error in chrome dev tools: '''Error: Failed to complete negotiation with the server: Error

https://localhost:5000/myfeature/_blazor/negotiate 404'''

我相信这是由于signalR集线器映射到 https://localhost:5000/引起的,但是我不知道如何添加其他blazor hub映射或如何更改blazor.server.js以使用根集线器.

I believe this is caused by the signalR hub being mapped to https://localhost:5000/, but I not sure how to add additional blazor hub mappings or how to change blazor.server.js to to use the root hub.

推荐答案

嘿,我们也发现自己遇到了同样的问题.更好的解决方案是指定<base href="~/"/>在html的开头,只引用<script src="_framework/blazor.server.js"/>

Hey we also found ourself with the same issue.A better solution would be to specify <base href="~/"/>in the head of the html and just referencing <script src="_framework/blazor.server.js"/>

如此

<html>
<head>
<base href="~/"/>
</head>
<body>

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

这篇关于如何在使用区域的剃须刀组件库中使用blazor服务器端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 02:35