如何使用子路径设置URL路由
我是WebAPI和MVC的新手。如果我想将服务URL分组为
- /api/account/create
- /api/account/login
- /api/account/resetpass
,我能够将所有3个方法调用放在同一控制器文件中,并以某种方式将特定请求映射到正确的方法?
i am new to webapi and MVC in general. If I wanted to group my service URLs like this
- /api/account/create
- /api/account/login
- /api/account/resetpass
Am I able to put all 3 method calls in the same controller file and somehow map a particular request to the right method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个名为
帐户
的控制器,然后创建3 [获取,发布,put,删除]方法,并将其命名创建,登录,resetpass
。默认情况下,这是MVC / API的路由(ID可以是可选的)
路由模板:“ API/{Controller}/{ID}”,
示例:
如果您打电话给它们,请尝试给他们特定的路线:
如果您遇到任何错误或误解,请don'犹豫发表评论
Create a Controller named
Account
and Create 3 [GET, POST, PUT, DELETE] method and name themcreate , login ,resetpass
.By Default, this is the routing for MVC / API(Id can be optional)
route Template: "api/{controller}/{id}",
Example :
if you had trouble calling them, try to give them a specific route :
Please if you get any error or misunderstanding, don't hesitate to post a comment