[英]How do I specify the route in WebApi
如何在路由中指定以下URL格式,并在以下位置访问变量(服务ID,安全ID,writedataflag):
https://<Domain Name or localhost<Port No>>api/<service Id>/<security id>/<writedataflag>
Configure the route template. 配置路由模板。
The following example uses Attribute Routing on a controller action. 以下示例在控制器操作上使用属性路由。
//matches GET api/<service Id>/<security id>/<writedataflag>
[HttpGet]
[Route("api/{service_id}/{security_id}/{writedataflag}")]
public IHttpActionResult MyAction(int service_id, int security_id, string writedataflag){
//...
}
the parameter types can be changed to suit your needs. 可以更改参数类型以适合您的需求。 Also consider using parameter constraints.
还可以考虑使用参数约束。
Read more about that here 在这里阅读更多关于
Attribute Routing in ASP.NET Web API 2 ASP.NET Web API 2中的属性路由
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.