Is it possible to download a file over Https in Windows phone , post method with username and password , I tried this code but it returns an error.
Note that the urlLink is an “https://” Link.
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);
Error :
The remote server returned an error: NotFound.
Because it’s a
https(usesSSL), the phone requires the server’s certificate to be downloaded and installed before any access to it is allowed.EDIT: Added my comment to this answer, and removed the comment.
Here’s a link to MSDN documentation about the subject http://msdn.microsoft.com/en-us/library/ms731899.aspx
If the certificate is self-signed, you can download and install it with the emulator, provided you have the certificate uploaded to somewhere you can download it from. Do notice, that the certificate needs to be installed everytime the emulator is started (not everytime the application debug is started though).