[英]Common Url for server and client in Blazor
Hello i do not understand the following: 您好,我不了解以下内容:
What i want to achieve: 我要实现的目标:
I have a ASP NET Core
standalone project that responds with some json to the followig routes : localhost:8300/a
我有一个ASP NET Core
独立项目,该项目以一些json响应followig路由: localhost:8300/a
localhost:8300/b
Now i am adding to the solution a simple Blazor
project template (not server-sided ,nor client-hosted ) ,just the client project. 现在,我向解决方案中添加了一个简单的Blazor
项目模板(不是服务器端的,也不是客户端托管的),只是客户端项目。
How do i set the Url
for the client
and the server
so that i can still respond with json on the mentioned routes , (example from Postman
) but i can acess the Blazor
client on some chosen route: 我如何为client
和server
设置Url
,以便我仍然可以在提到的路由上以json进行响应(例如Postman
示例),但是我可以在某些选定的路由上访问Blazor
客户端:
[address]:[port]/c
I do not understand the address and the port part. 我不了解地址和端口部分。
Main idea with .NET Code integration for these sorts of problems is create separate WebApplication which will just add references to you API
and BlazorClient
client projects. 解决此类问题的.NET代码集成的主要思想是创建单独的WebApplication,它将仅向您的API
和BlazorClient
客户端项目添加引用。 Lets call that new App CombinedApp
for clearer reference. 让我们调用新的App CombinedApp
以获得更清晰的参考。
if you duplicate initialization of API
inside CombinedApp
. 如果您在CombinedApp
重复API
初始化。 Inside Startup
class you should perform same initialization inside ConfigureServices
and Configure
methods. 在Startup
类中,应在ConfigureServices
和Configure
方法中执行相同的初始化。 That bring routes from API
project to the CombinedApp
project. 这将路由从API
项目路由到CombinedApp
项目。 Then add UseBlazor<BlazorClient.Program>()
in the Configure
method of CombinedApp.Startup
and then you have both API and BlazorClient sitting in the same project. 然后加入UseBlazor<BlazorClient.Program>()
在Configure
的方法CombinedApp.Startup
,然后你有两个API和BlazorClient坐在同一个项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.