I am trying to get a response xml from the UIDAI data centers by sending an xml document using HttpWebRequest and receiving it using HttpWebResponse in C#ASP.net web based application. I already checked it using a java application and it is working fine on their side but the web based application is throwing an exception
An exception of type 'System.Net.WebException' occurred in System.dll but was not handled in user code
Note:The web exception occurs on the 5th line from the last
Please suggest some methods to resolve this
public void SendForAuthentication()//user defined function for Sending and Receiving Requests
{
string url = "http://auth.uidai.gov.in/1.6/public/9/9/MLTbKYcsgYMq1zgL3WMZYrnyvsarlljxpom2A-QTPc0Zud23shpnqPk";//the host address
StreamReader sr1 = new StreamReader("D:\\test-signed.xml");//loading xml file to stream
string XMLData = sr1.ReadToEnd();
string Conn = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>";
XMLData = Conn + XMLData;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
byte[] requestBytes = System.Text.Encoding.UTF8.GetBytes(XMLData);
req.Method = "POST";
req.ContentType = "text/xml;charset=utf-8";
req.ContentLength = requestBytes.Length;
Stream requestStream = req.GetRequestStream();
requestStream.Write(requestBytes, 0, requestBytes.Length);
requestStream.Close();
HttpWebResponse response = (HttpWebResponse)req.GetResponse();//**here I am getting a webexception**
StreamReader sr = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);
string backstr = sr.ReadToEnd();
reader.ReadToFollowing("title");
File.WriteAllText("D:\\xml.xml", backstr);
}
edit: The exception I get is "the operation has timed out" though I had increased the operation time
edit2: The above code works fine there was actually a problem with my firewall