是否可以在 Windows 手机中通过 Https 下载文件,使用用户名和密码发布方法,我尝试了此代码,但它返回错误。请注意,urlLink 是一个“https://”链接。
Uri uri = new Uri(urlLink);
HttpWebRequest r = (HttpWebRequest)WebRequest.Create(uri);
r.ContentType = "application/x-www-form-urlencoded";
r.Method = "POST";
string parameters = "username=admin&password=123";
r.BeginGetRequestStream(delegate(IAsyncResult req)
{
var outStream = r.EndGetRequestStream(req);
using (StreamWriter w = new StreamWriter(outStream))
w.Write(parameters);
r.BeginGetResponse(delegate(IAsyncResult result)
{
try
{
HttpWebResponse response = (HttpWebResponse)r.EndGetResponse(result);
using (var stream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(stream))
{
}
}
}
catch (Exception exc)
{
string ee = exc.Message;
}
}, null);
}, null);
错误 :
远程服务器返回错误:NotFound。