简体   繁体   English

Blazor 以 WebAPI 后端托管的服务器

[英]Blazor Server Hosted with WebAPI backend

So much has changed since I last did any development so please bear with me,自从我上次进行任何开发以来发生了很多变化,所以请耐心等待,

Overview概述

My knowledge level我的知识水平

Been picking up C# in assisting bug hunting in a server-hosted application, before this it was Java for IRC bots and PHP 5.6.一直在使用 C# 协助在服务器托管的应用程序中寻找错误,在此之前它是 Java 用于 IRC 机器人和 PHP 5.6。 ( Oof, I just made myself feel old ) 哎呀,我只是让自己觉得自己老了

Backstory背景故事

I've been building my knowledge and reading various tutorials and Microsoft Documentation ( Which has caused me so much more confusion as to what I need/want ) that I want to settle on a RESTful data flow like the image below.我一直在积累我的知识并阅读各种教程和 Microsoft 文档(这让我对我需要/想要的东西更加困惑),我想确定一个 RESTful 数据流,如下图所示。

Data Access Model that shows relationship from Client to Blazor Server to RESTful server to database and back again数据访问 Model,显示从客户端到 Blazor 服务器到 RESTful 服务器到数据库的关系,然后再返回

I found tutorials ( Example from Pragim - I followed the text, not videos) and it talks about ASP.Net Core Identity on the Blazor Server level.我找到了教程( 来自 Pragim 的示例- 我关注的是文本,而不是视频)并且它讨论了 Blazor 服务器级别的 ASP.Net Core Identity。 To me, it makes more sense to move it to the RESTful server ( Which I now understand use the ASP.Net WebAPI ) level, since I want to be able to later develop different front end, for example, a front end Android app later on and still maintain the same backend for authorization, authentication, and data management.对我来说,将它移动到 RESTful 服务器(我现在知道使用 ASP.Net WebAPI )级别更有意义,因为我希望以后能够开发不同的前端,例如,稍后开发前端 Android 应用程序上并仍然维护相同的后端以进行授权、身份验证和数据管理。

I've looked around for more tutorials and found Securing Client-Side Blazor with WebApi tutorial but it talks about Blazor WebAssembly.我四处寻找更多教程并找到了使用 WebApi 教程保护客户端 Blazor,但它谈到了 Blazor WebAssembly。 I'm feeling overloaded with too much information.我感觉信息太多了。

Goal目标

I want to provide a loosely coupled Management System to help me manage my first responder volunteer unit.我想提供一个松散耦合的管理系统来帮助我管理我的急救志愿者单位。 Unit members would use the system for tracking their hours, seeing and tracking certification expiry, leadership in various roles and levels would use it to see reports of hours, sending notification in the chain of command way, and other features I feel the system needs.单位成员会使用该系统来跟踪他们的工作时间,查看和跟踪证书到期时间,不同角色和级别的领导会使用它来查看工作时间报告,以命令链方式发送通知,以及我认为系统需要的其他功能。 Similar to an employee management system.类似于员工管理系统。

There's also a possibility of growing from my local unit of up to 50 members, to a council of 3-5 units, and a rare possibility of nationwide hence my need to be loosely coupled as the tech at different levels may need to be swapped out although that's beyond the scope of current development, the scope is to learn and have a working system for my unit, I feel the need to design in a way that growing/adapting is easier.也有可能从最多 50 个成员的本地单位发展到 3-5 个单位的理事会,并且在全国范围内的可能性很小,因此我需要松散耦合,因为可能需要交换不同级别的技术虽然这超出了当前开发的 scope,但 scope 是学习并拥有适合我单位的工作系统,我觉得需要以一种更容易成长/适应的方式进行设计。

My understanding of Blazor WebAss vs Blazor Server hosting is that WebAss download all of the logic, while the Server rendered the content on the server-side and only the change is sent and I went with the server since it could be accessed via devices that are on wireless access like 4G, etc and reducing bandwidth and processing usage is key.我对 Blazor WebAss 与 Blazor 服务器托管的理解是 WebAss 下载所有逻辑,而服务器在服务器端呈现内容并且只发送更改,我选择了服务器,因为它可以通过以下设备访问在 4G 等无线接入上,减少带宽和处理使用是关键。 I am settled on using ASP.Net, C# as full-stack as I can.我决定尽可能全栈地使用 ASP.Net,C#。 Blazor Server and Web API are separate but locally hosted. Blazor 服务器和 Web API 是分开的,但在本地托管。

============== ==============

Summary TL;DR:总结 TL;DR:

How to use Blazor Server Hosted to access WebAPI server to authenticate/authorize?如何使用Blazor Server Hosted访问WebAPI服务器进行认证/授权? Is it even possible to allow sign up with external services like Google, Microsoft, and Facebook with this setup?使用此设置甚至可以允许注册外部服务,例如 Google、Microsoft 和 Facebook 吗?

The short answer is Yes, you can call external API's in the same app, use Identity and Identity already has the ability to authenticate via google/ms/fb.简短的回答是,您可以在同一个应用程序中调用外部 API,使用 Identity 并且 Identity 已经能够通过 google/ms/fb 进行身份验证。

However Blazor server is prone to latency(it would matter where the server is) and requires a decent connection.但是 Blazor 服务器容易出现延迟(服务器在哪里很重要)并且需要良好的连接。 I would question its place here.我会质疑它在这里的位置。

Blazor webassembly is a client side UI framework and it would be easier later if you where inclined to removed it as your webapi is separate. Blazor webassembly 是一个客户端 UI 框架,如果您倾向于删除它,以后会更容易,因为您的 webapi 是独立的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有托管的 Blazor WebAssembly 作为客户端与 .Net Core WebAPI 作为服务器端交互 - Blazor WebAssembly without hosted act as client side interact with .Net Core WebAPI as server side 配置 Blazor 服务器以托管 WebAPI - Configure Blazor Server to host WebAPI 删除自托管 WebApi 响应中的服务器标头 - Remove server header in self hosted WebApi response Blazor 服务器应用托管在 Windows 服务中 - Blazor server app hosted in Windows service 站点上托管的 Blazor 服务器中的相对文件路径 - Relative File Path in Blazor Server hosted on Site Blazor WASM Asp.net 核心是否托管 = Blazor 服务器端? - Is Blazor WASM Asp.net core Hosted = Blazor server side? blazor 服务器应用程序中的自定义 loginwebapi 问题(使用内置 webapi 框架) - issue with custom loginwebapi in blazor server app(use built in webapi framework) 如何在客户端(blazor webassembly)调用create webapi(blazor server app) - how to call create webapi(blazor server app) in client side(blazor webassembly) 如何在 blazor webassembly 应用程序(客户端)中调用 blazor 服务器应用程序(登录 webapi) - how to call blazor server app(login webapi) in blazor webassembly app(client side) 在 blazor 中使用带有身份验证的 WebAPI - Consuming WebAPI in blazor with authentication
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM