简体   繁体   English

在 ASP.NET Core 中为多步注册表单实现 REST API 的正确方法是什么?

[英]What is the proper way to implement a REST API for multi-step registration form in ASP.NET Core?

I need to develop a REST API for a new user registration form which consists of 2 steps.我需要为一个新的用户注册表单开发一个 REST API,它由 2 个步骤组成。 Step 1 validates email and password requirements.第 1 步验证电子邮件和密码要求。 The data gets saved into the database on Step 2 after the user specifies valid country and region.在用户指定有效的国家和地区后,数据将在第 2 步保存到数据库中。 What is the recommended approach in such scenarios?在这种情况下推荐的方法是什么? Using different endpoints for step 1 and 2, like /users/password and /users/location?对第 1 步和第 2 步使用不同的端点,例如 /users/password 和 /users/location? Using a single endpoint, but having some info about the current step as part of the Dto?使用单个端点,但将有关当前步骤的一些信息作为 Dto 的一部分? Anything else?还要别的吗?

Hi你好
you can use both of the options i my self used both of them but in my experience using a multi endpoint is more maintainable.您可以使用我自己使用的两个选项,但根据我的经验,使用多端点更易于维护。 And also it good match for single-responsibility principle (SRP)并且非常适合单一职责原则(SRP)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM