The problem is the url for download is not appropriate when you use it on non-browser..
Also spelling mistake on html input "Password"
Let me post a fully flexible code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
namespace CodeProjectDownload
{
class Program
{
static void Main(string[] args)
{
Download("xyx@domain.com", "mypassword", @"C:\Test", @"http://www.codeproject.com/KB/IP/SimpleFTPDemo/SimpleFTP20_src.zip");
}
private static void Download(string email, string password, string destination, string downloadUri)
{
using (CookiesAwareWebClient client = new CookiesAwareWebClient())
{
NameValueCollection values = new NameValueCollection();
values.Add("Email",email );
values.Add("Password", password);
values.Add("x", "10");
values.Add("y", "10");
values.Add("login", "login");
client.UploadValues("https://www.codeproject.com/script/Membership/LogOn.aspx?rp=%2f", values);
string modifieduri = "http://www.codeproject.com/script/articles/download.aspx?file=" + downloadUri.Replace("http://www.codeproject.com","") + "&rp=";
string filename = System.IO.Path.GetFileName(downloadUri);
string filepathname = System.IO.Path.Combine(destination, filename);
client.DownloadFile(modifieduri, filepathname);
}
}
}
}