Basic authentication

Hi guys,
I’ve a problem when I try to login in sites that use basic authentication. What script should I use? I program in C# and now i try this method to generate url:

string urlString = _phpUrl + “runtest.php?url=” + url + “&location=” + agentName + “.custom&aftec=25&fvonly=0&plr=0&latency=28&bwUp=1000&bwDown=” + bwDown + “&video=on&runs=1&f=xml”;
string encoded = System.Convert.ToBase64String(Encoding.GetEncoding(“ISO-8859-1”).GetBytes(username + “:” + password));
string toEncode = string.Empty;
toEncode += string.Format(“setHeader\tAuthorization\tBasic\t” + encoded);
urlString += HttpUtility.UrlEncode(toEncode)

Thanks in advance,
Jak