在WebApi中路由到特定的URL [英] Routing in WebApi to a specific url

查看:346
本文介绍了在WebApi中路由到特定的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我有一个关于WebApi路由的问题.
首先,可以在WebApi中路由此类网址,请参见以下内容:

..../api/physiciansiansregister/{id}/status

我需要将该URL路由到具有下一个签名的方法:

Hello, I have a question concerns WebApi routing.
First of all is it possiple to route such kind of url in WebApi, see below:

..../api/physiciansregister/{id}/status

I need to rout that url to method which has, next signature:

[HttpPost]
public void Status(int id, StatusInfo status)
{

}


有关状态的信息将在POST方法中传输,并将以JSON的形式表示
正文:
{状态":在线"}

状态实体:


information about status wiil be transfered in POST method and will be represented like JSON
Body:
{"Status":"Online"}

Status entity :

class StatusInfo
{
string Status {get;set;}
}


伙计们,有什么想法吗?)


Guys, any thoughts??)

推荐答案

请参阅http://www.asp.net/web-api/overview/web-api-routing-and-actions/routing -in-aspnet-web-api [

这篇关于在WebApi中路由到特定的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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