如何使用.NET核心在web api2.0中创建路由 [英] How to create routing in web api2.0 with .NET core

查看:72
本文介绍了如何使用.NET核心在web api2.0中创建路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

传统方法或基于属性的路由更合适。我可以在我的应用程序中使用这两种路由给我一些关于这个的想法。



谢谢



我尝试了什么:



传统方法或基于属性的路由更合适。我可以在我的应用程序中使用这两种路由给我一些关于这个的想法。



谢谢

解决方案

当然你可以混合常规路由或基于属性的路由。对于为浏览器提供HTML页面的控制器,以及为REST API提供服务的控制器的属性路由,通常使用传统路由。话虽如此,并且在我看来,属性路由是构建REST API的理想选择。



继续阅读: ASP.NET核心路由Microsoft Docs [ ^ ]

Conventional-approach or, attribute based routing which one more appropriate. Can i use both routing in my application. Give me some idea about this.

Thanks

What I have tried:

Conventional-approach or, attribute based routing which one more appropriate. Can i use both routing in my application. Give me some idea about this.

Thanks

解决方案

Surely you can mix conventional or attribute based routing. It's typical to use conventional routes for controllers serving HTML pages for browsers, and attribute routing for controllers serving REST APIs. Having that said, and in my own opinion, Attribute routing is ideal for building REST API's.

Read on: Routing in ASP.NET Core | Microsoft Docs[^]


这篇关于如何使用.NET核心在web api2.0中创建路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆