我正在编写一个简单的 Silverlight 应用程序,其中包含以下代码,我认为这是非常标准的:
WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
var request = new WebClient();
var cred = new NetworkCredential(Server.UserName, Server.Password);
request.Credentials = cred;
request.UseDefaultCredentials = false;
request.DownloadStringCompleted += TestServerCompleted;
var uri = new Uri(Server.GetRequestUrl(Methods.ping));
request.DownloadStringAsync(uri);
然而,当我在 Fiddler 中查看请求时,标题中没有添加任何凭据。我错过了什么?那里不应该有一个“授权:基本......”标题吗?