English 中文(简体)
Blazor WebAssembly的客户方行道: browser所在地的租户名称
原标题:Blazor WebAssembly client side routing: Tenant name in browser location

我拥有一个布茨or WebAssembly,希望确定来自URI的租户,并随时在URI展示浏览器地址的租户口。

在服务器一旁,我添加了一台中层设备,从申请的URI公路中确定租户,并管理迄今为止行之有效的路由。

But at the client side I just don t get it: When I navigate to https://domain/tenant, everything is fine, the app starts and displays a page. But when I click on a link and navigate to any other page, the URI in the browsers address bar looks like https://domain/page_route - instead of https://domain/tenant/page_path.

因此,我的问题是:在浏览器在酒吧的地址总是可以看到,我如何拦截车道(从请说的<代码>Tenant.Current.Alias到)?

例:

  • The user calls https://domain, which uses the default tenant tenant
  • The user clicks on a link which routes to page_path, which should result in the URI https://domain/tenant/page_path then

另一个例子:

  • The user calls https://domain/tenant
  • The user clicks on a link which routes to page_path, which should result in the URI https://domain/tenant/page_path then

顺便提一下,针对APIC申请,I ve 修改了<代码>HttpClient在客户中注射,并将BaseAddress改为“URI”,其中包括租户。 这符合APIC的要求,但当然不影响正在浏览器地址展示的URI。

www.un.org/Depts/DGACM/index_spanish.htm 现在,我得出结论,我需要把所有页线连接起来,而URI在服务器方面也没有重写。

最佳回答

最后,我做了发言:这一trick子是要修改<条码><>底线/代码>标签(<条码>index.html<>。 因此,它包括租户。

For this I deleted the index.html, created a Index.cshtml as new server page and changed the default routing to use the Index.cshtml, before looking for a index.html. Then it was required to redirect a browser, which calls an URI without the tenant alias in the request URI path.

在客户I更新了导航,将@(”/“+tenantAlias+”/anything”>作为href。 在Razor网页上,我可以从航线上删除租户,因为导航管理员使用<条码>底线<<> 代码>href,并将其与一个页线合并。

This is way more complicated as at the server side, but it seems to be the correct way, since it s not possible to modify the URI which is used by the NavigationManager, and this base URI is initialized only once during bootstrapping (that s why a browser redirect is required).

UPDATE for .NET 8:

由于网络8做了一些改动,现在整个事情更加容易。 安装一个完整的脱盲项目似乎太大,但现在可以找到一个在线项目:

https://github.com/nd1012/Demo/tree/ASP.NET-Tenant-URI?tab=readme-ov-file

最新承诺显示了整个工作解决办法,这些变化必须适用于平原项目,以便使其发挥作用:

https://github.com/nd1012/Demo/commit/9c9fad84253dc05dc7f4de29d017b54091a73e7b

问题回答

暂无回答




相关问题
Blazor web assembly pass checkbox list values to model

I m new to Blazor. I m working in a web assembly Blazor project. I am trying to create a form that passes values back to a model. I have it working with input text fields and drop downs, but I am ...

How to make Core Blazor CSS isolation work?

I have the BadgeDemoPage component represented with the following files: Unfortunately, the styles has not been applied. Of course, I have read the ASP.NET Core Blazor CSS isolation documentation. As ...

热门标签