【发布时间】:2013-12-16 01:56:25
【问题描述】:
我正在尝试测试我的 Web API
[Test]
public void PolicyController_GetFirstPage_Successful()
{
using (var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api/policies/~/~/0"))
{
using (var response = Client.SendAsync(request, CancellationToken.None).Result)
{
//blah blah
}
}
}
但我的控制器的操作具有[Authorize] 属性,所以我收到未经授权的错误。
我该如何处理这种情况?
【问题讨论】:
标签: c# asp.net testing asp.net-web-api