Hi, My name is krishna. I am using asp.net 2.0 with C#. I amusing Windows XP professional as OS. When I post some data to an external web server I get the error as "The Remote server returned an error :(407) Proxy Authentication Required ".
Here is the code I am using, Please help me out at the earliest.
But when I do the above, I get the error as ""The Remote server returned an error :(407) Proxy Authentication Required ".
Kindly help me out.
thanks
casukhela krishna
Here is the code I am using, Please help me out at the earliest.
Code:
public void JACCS_Response(string date,string jaccs_id,string irn,string company_id,string xmlid) { string responseString = string.Empty; // I am passing the following 4 parameters to the site. string REQ_STR = "SEND_DATETIME=" + date + "&KAMEITEN_BANGO=" + company_id + "&JACCS_DENPYO_BANGO=" + jaccs_id + "&DENPYO_BANGO=" + irn; try { HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create(ConfigurationManager.AppSettings["someurl"].ToString()); //The app.config file contains the URL to which I post the data webreq.Method = "POST"; //WebProxy myProxy = new WebProxy(ConfigurationManager.AppSettings["proxy"].ToString(), 80); WebProxy myProxy = new WebProxy("someproxy"); //The proxy is specified in the app.config //required only for local development myProxy.Credentials = System.Net.CredentialCache.DefaultCredentials; //myProxy.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["ProxyUID"].ToString(), ConfigurationManager.AppSettings["ProxyPwd"].ToString(), ConfigurationManager.AppSettings["ProxyDomain"].ToString()); webreq.Proxy = myProxy; //I specify the userid, password and the domain needed to access the external site webreq.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["userid"].ToString(), ConfigurationManager.AppSettings["pwd"].ToString(), ConfigurationManager.AppSettings["domain"].ToString()); byte[] byteArray = Encoding.GetEncoding("shift-jis").GetBytes(REQ_STR); webreq.ContentLength = byteArray.Length; webreq.ContentType = "application/x-www-form-urlencoded"; webreq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GoogleT5; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)"; using (Stream myStream = webreq.GetRequestStream()) { try { myStream.Write(byteArray, 0, byteArray.Length); myStream.Flush(); } catch (Exception e) { throw e; } } // Get the response. HttpWebResponse response = (HttpWebResponse)webreq.GetResponse(); StreamReader ResponseStream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("shift-jis")); responseString = ResponseStream.ReadToEnd(); ResponseStream.Close(); response.Close(); } catch (Exception ex) { throw ex; } }
Kindly help me out.
thanks
casukhela krishna
Comment