Asp.net mvc 4 Web API示例
有人能给我指一个合适的例子吗Asp.net mvc 4 Web API示例,asp.net-mvc-4,asp.net-web-api,put,Asp.net Mvc 4,Asp.net Web Api,Put,有人能给我指一个合适的例子吗 我遇到的一切都不一致。认为你已经在控制器中了 [HttpPut] public HttpResponseMessage MyPutAction(myModelType MyModel) { .... // here is some code that will update the record and return it as part of HttpResponseMessage .... 或 在第二个示例中,MVC框架知道这是基于
我遇到的一切都不一致。认为你已经在控制器中了
[HttpPut]
public HttpResponseMessage MyPutAction(myModelType MyModel)
{
....
// here is some code that will update the record and return it as part of HttpResponseMessage
....
或
在第二个示例中,MVC框架知道这是基于方法名称的[Put]。所以你不需要用[HttpPut]来装饰它
或
听起来很愚蠢,但工作原理与上面的一样。同样,MVC框架知道这是基于方法名的[Put],因为它以“Put”开头
public HttpResponseMessage Put(myModelType MyModel) ....
public HttpResponseMessage PutMyModel(myModelType MyModel) ....