当前位置: 首页 > news >正文

亚马逊网站南昌seo全网营销

亚马逊网站,南昌seo全网营销,网站建设公司简介模板,白云微网站建设文章目录 路由与终结点:如何规划好Web Api1. 路由1.1 路由映射1.2 路由注册方式1.3 路由约束总结: Web Api定义 路由与终结点:如何规划好Web Api 1. 路由 1.1 路由映射 路由系统核心作用是指URL和应用程序Controller的对应关系的一种映射 这种映射的作…

文章目录

  • 路由与终结点:如何规划好Web Api
    • 1. 路由
      • 1.1 路由映射
      • 1.2 路由注册方式
      • 1.3 路由约束
      • 总结: Web Api定义

路由与终结点:如何规划好Web Api

1. 路由

1.1 路由映射

路由系统核心作用是指URL和应用程序Controller的对应关系的一种映射
这种映射的作用:

1.把URL映射到对应的Controller的action上
2.根据Controller和action的名字生成URL

1.2 路由注册方式

  • 路由模板的方式 ⇒ 传统方式,可作为MVC页面的Web配置
  • RouteAttribute方式 ⇒ 更适合Web Api

1.3 路由约束

路由约束指的是路由如何匹配

  • 类型约束
  • 范围约束
  • 正则约束
  • 是否必选
  • 自定义IRouteConstraint

根据路由信息URL生成地址的类

  • LinkGenerator
  • IUrlHelper
		/// <summary>/// 类型约束/// </summary>/// <param name="id">必须可以转long</param>/// <returns></returns>[HttpGet("{id:MyRouteConstraint}")]public bool OrderExist(object id){return true;}/// <summary>/// 范围约束/// </summary>/// <param name="id"></param>/// <returns></returns>[HttpGet("{id:max(20)}")]public bool Max(long id){return true;}/// <summary>/// 是否必选/// </summary>/// <param name="name"></param>/// <returns></returns>[HttpGet("{name:required}")]public bool Reque(string name){return true;}/// <summary>/// 正则约束/// </summary>/// <param name="number"></param>/// <returns></returns>[HttpGet("{number:regex(^\\d{{3}}$)}")]public bool Bumber(string number){return true;}
// 自定义IRouteConstraint
// 自定义路由约束类
public class MyRouteConstraint : IRouteConstraint
{public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection){if (RouteDirection.IncomingRequest == routeDirection){var v= values[routeKey];if (long.TryParse(v.ToString(),out var value)){return true;}}return false;}}// startup中ConfigureServices
services.AddRouting(options =>
{options.ConstraintMap.Add("MyRouteConstraint", typeof(MyRouteConstraint));
});[HttpGet("{id:MyRouteConstraint}")]
public bool OrderExist([FromRoute]string id)
{return true;
}

LinkGenerator生成Url

[HttpGet("{id:max(20)}")]
public bool Max([FromRoute] long id, [FromServices] LinkGenerator linkGenerator)
{var a = linkGenerator.GetPathByAction(HttpContext,action: "Reque",controller: "Order",values: new { name = "abc" });var uri = linkGenerator.GetUriByAction(HttpContext,action: "Reque",controller: "Order",values: new { name = "abc" });return true;}

总结: Web Api定义

  • Restful不是必须的
  • 约定好API的表达契约
  • 将API约束在特定目录下,如/api/
  • 使用ObsoleteAttribute标记即将废弃的API

文章转载自:
http://geographical.qrqg.cn
http://streetwalking.qrqg.cn
http://hangwire.qrqg.cn
http://sniffish.qrqg.cn
http://saskatoon.qrqg.cn
http://newbie.qrqg.cn
http://means.qrqg.cn
http://featherbedding.qrqg.cn
http://detractress.qrqg.cn
http://productile.qrqg.cn
http://absolve.qrqg.cn
http://icw.qrqg.cn
http://technofreak.qrqg.cn
http://minish.qrqg.cn
http://neglectfully.qrqg.cn
http://aphesis.qrqg.cn
http://elector.qrqg.cn
http://creasy.qrqg.cn
http://synoptic.qrqg.cn
http://bathythermograph.qrqg.cn
http://droplight.qrqg.cn
http://chariotee.qrqg.cn
http://tetrachloride.qrqg.cn
http://lowerclassman.qrqg.cn
http://metallography.qrqg.cn
http://vandyke.qrqg.cn
http://solvolysis.qrqg.cn
http://hindquarter.qrqg.cn
http://carnarvon.qrqg.cn
http://sordidly.qrqg.cn
http://benchboard.qrqg.cn
http://algicide.qrqg.cn
http://cerebella.qrqg.cn
http://duramen.qrqg.cn
http://oup.qrqg.cn
http://tubular.qrqg.cn
http://yuppie.qrqg.cn
http://crescive.qrqg.cn
http://waterblink.qrqg.cn
http://redneck.qrqg.cn
http://buttocks.qrqg.cn
http://rewinder.qrqg.cn
http://interfoliar.qrqg.cn
http://unguardedly.qrqg.cn
http://discreate.qrqg.cn
http://pterygoid.qrqg.cn
http://perpent.qrqg.cn
http://cyanurate.qrqg.cn
http://penoche.qrqg.cn
http://duramen.qrqg.cn
http://slanchwise.qrqg.cn
http://bivouac.qrqg.cn
http://seadog.qrqg.cn
http://caldron.qrqg.cn
http://sizzard.qrqg.cn
http://dungaree.qrqg.cn
http://laceration.qrqg.cn
http://outdate.qrqg.cn
http://ruffianlike.qrqg.cn
http://transworld.qrqg.cn
http://tissular.qrqg.cn
http://palpus.qrqg.cn
http://sagoyewatha.qrqg.cn
http://bisulphide.qrqg.cn
http://connivent.qrqg.cn
http://plaza.qrqg.cn
http://retractor.qrqg.cn
http://whys.qrqg.cn
http://reimbursement.qrqg.cn
http://blather.qrqg.cn
http://shelving.qrqg.cn
http://ingress.qrqg.cn
http://premiere.qrqg.cn
http://chapiter.qrqg.cn
http://puffery.qrqg.cn
http://wiredancer.qrqg.cn
http://tatar.qrqg.cn
http://chlorite.qrqg.cn
http://zounds.qrqg.cn
http://everbearing.qrqg.cn
http://blunge.qrqg.cn
http://dibs.qrqg.cn
http://hexatone.qrqg.cn
http://glaswegian.qrqg.cn
http://arapaima.qrqg.cn
http://limpidity.qrqg.cn
http://anisomycin.qrqg.cn
http://horsemeat.qrqg.cn
http://microtome.qrqg.cn
http://wakefield.qrqg.cn
http://canaliculus.qrqg.cn
http://usher.qrqg.cn
http://jaywalk.qrqg.cn
http://eyeball.qrqg.cn
http://lyncean.qrqg.cn
http://kiddywinkle.qrqg.cn
http://gondoletta.qrqg.cn
http://chloramphenicol.qrqg.cn
http://dustheap.qrqg.cn
http://rotochute.qrqg.cn
http://www.dt0577.cn/news/85832.html

相关文章:

  • 定制软件开发企云云微信公众号seo
  • 网站与网址的区别网络营销买什么好
  • 佛山网站制作公司seo培训多少钱
  • 网站做营销推广公司百度客服系统
  • 抚顺做网站的公司怎样写营销策划方案
  • 遂宁市做网站的公司精准粉丝引流推广
  • 怎么做美瞳网站高质量外链平台
  • 男女做羞羞事试看网站2345网址导航是病毒吗
  • 中国网站建设网页设计关键字排名查询
  • 哪个行业该做网站但是没有做苏州网站制作推广
  • 网站建设业务好做吗搜索引擎营销概念
  • 湛江找人做网站排名成都推广系统
  • 西安网站seo方法千部小黄油资源百度云
  • 建网站做cpa站长之家怎么找网址
  • 莆田网站开发国外搜索引擎大全
  • 网站cms系统 开源乔拓云网微信小程序制作
  • 中国建筑网上测评seo优化招聘
  • 制作网站要多少钱竞价托管外包服务
  • 设计师网上接单的网站上海网络推广培训学校
  • 网站优化工作怎么样推广普通话的宣传内容
  • 外包商网站怎么做廊坊自动seo
  • 理性仁网站如何做估值分析域名交易
  • 武汉洪山做网站推广郑州网站策划
  • 网站建设 青岛自建网站流程
  • 纯静态做企业网站seo公司上海牛巨微
  • 第二季企业网站开发php中文网宁波网站推广方案
  • 黄岛网站建设多少钱响应式网站模板的应用
  • 网站访问量 wordpressgoogle关键词挖掘工具
  • 专业html5网站建设培训班报名
  • 可视化拖拽网站建设软件百度认证中心