比特授权不发送

时间:2016-10-28 14:41:32

标签: c# asp.net-web-api2 microsoft-bits

我想使用BITS在客户端和自定义服务器之间传输一些文件。服务器使用ASP.NET web api控制器托管在IIS中。我正在尝试将凭据发送到服务器以仅授权从我的客户端下载,但我无法通过c#在服务器上恢复这些凭据。我无法在标题中或请求中的任何位置找到它(我试图通过WireShark进行分析)。

以下是我用来在客户端上创建BITS作业的命令行。

bitsadmin /Create "testCredentials2"
bitsadmin /AddFile "testCredentials2" "http://10.0.0.146/df/api/docs/downloaddummy" "D:\temp\fileoverBits"
bitsadmin /SetCredentials "testCredentials2" SERVER BASIC "login" "password"
bitsadmin /Resume "testCredentials2"

修改

有人在我问道后帮我找到了答案。我的api首先应该回复一个要求进行身份验证的回复。就这样做了

var response = new HttpResponseMessage(HttpStatusCode.Unauthorized);
response.Headers.Add("WWW-Authenticate", "Basic realm=\"localhost\"");
return response;

0 个答案:

没有答案