当我使用webapi 2时,我想在我的http响应中添加一个Location头部。下面的方法展示了如何使用命名路由来实现这一点。有人知道您是否可以使用webapi 2中发布的属性路由功能来创建Url.Link吗?string uri = Url.Link("DefaultApi", new { id = reponse.Id });
httpResponse.Headers.Location = new Uri
我想对异步控制器进行单元测试。我以前已经做过很多次了,但从未调用Url.Link()方法来生成位置标头。public class DemoController : ApiController [HttpPost] // generate url for location header (here the problem occurrs)