0

我正在关注本教程,并且在尝试编写此方法时遇到了困难:

public HttpResponseMessage PostProduct(Product item)
{
    item = repository.Add(item);
    var response = Request.CreateResponse<Product>(HttpStatusCode.Created, item);

    string uri = Url.Link("DefaultApi", new { id = item.Id });
    response.Headers.Location = new Uri(uri);
    return response;
}
  • 对象是什么命名空间Request?和 HTTPRequest 一样吗?如果是这样,那么为什么 Intellisense 不能帮助我完成它?(我得到未知的方法)

  • URL.Link对象/方法是什么命名空间?

我在 Bing 和 Google 中搜索了这些对象,但找不到与 Voice/SIP 无关的任何与 WepAPI 无关的内容

4

1 回答 1

0

You need to reference System.Net.Http, this should be all you need.

You can go and download the project, it might be worth doing this for reference.

Also, a good tool for helping with this type of issue and a lot more with development is Resharper.

于 2013-09-21T13:42:23.563 回答