How to run multiple Blazor apps in single website(如何在一个网站上运行多个Blazor应用)
问题描述
我要创建一个网站,其中某些子功能将拆分到多个Blazor项目中。 所以主站点是一个Blazor应用程序,但是/private和/shop是单独的Blazor应用程序,用户需要注册和登录才能访问功能。 由于主网站应该有所有网站通用的导航栏(有登录和注册按钮),如何在Blazor应用程序之间通信?
如果我在主站点上设置身份验证并使用主站点中的AppState存储值,则在/Private中运行的子应用如何访问此数据(例如,is Logging in或用户名数据)。
推荐答案
这看起来很有希望:Blazor with multiple apps
我也一直在试图弄清楚如何做到这一点。上面的例子展示了如何在一个解决方案中将两个客户端Blazor应用程序与单个服务器端Blazor应用程序链接起来。我从该示例中获得的主要内容是在服务器端应用程序启动时向配置添加的内容。
app.MapWhen(ctx => ctx.Request.Path.StartsWithSegments("/FirstApp"), first =>
{
first.UseBlazorFrameworkFiles("/FirstApp");
first.UseStaticFiles();
first.UseRouting();
first.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapFallbackToFile("FirstApp/{*path:nonfile}", "FirstApp/index.html");
});
});
app.MapWhen(ctx => ctx.Request.Path.StartsWithSegments("/SecondApp"), second =>
{
second.UseBlazorFrameworkFiles("/SecondApp");
second.UseStaticFiles();
second.UseRouting();
second.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapFallbackToFile("SecondApp/{*path:nonfile}", "SecondApp/index.html");
});
});
希望这对您有帮助。
这篇关于如何在一个网站上运行多个Blazor应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在一个网站上运行多个Blazor应用


基础教程推荐
- 将 XML 转换为通用列表 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- c# Math.Sqrt 实现 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 如何激活MC67中的红灯 2022-01-01