Sunday 15 May 2011

c# - Call to GetResponse() is throwing (500) Internal Server Error -


What is happening to throw this exception, and how can it be overcome?

I am passing a serialized XML file on an API post, and I hope for a return call.

Instead of throwing 500 internal server errors on my code GetResponse () call.

I have checked the syntax of my file, and it is correct. I also know that my argument works as I have used it for other calls.

  try {wWebRequest = (HttpWebRequest) WebRequest.Create (strWebAddressAuthentication); WWebRequest.CookieContainer = New Cookie Container (); WWebRequest.Method = SHTPPrint method; WWebRequest.ServicePoint.Expect100Continue = false; WWebRequest.UserAgent = sUserAgent; WWebRequest.ContentType = srequestContentType; FileInfo fInfo = New FileInfo (filename); Long numbytes = fInfo.Length; Double DLN = Convert. ToDouble (fInfo.Length / 1000000); If (DLAN & lt; 100) {fstream = new filestream (File name, open File MOD, FileAccess.Read); Br = new binary reader (Fstream); Data = br.ReadBytes ((int) numBytes); Br.Close (); WWebRequest.ContentLength = data.Length; Datastream = wWebRequest.GetRequestStream (); Datastream.Write (data, 0, data. Length); DataStream.Close (); Feedback = (HTTP webbense) wWebRequest.GetResponse (); Foreign (cookies in Cook Cookie Feedback) {myCookieContainer.Add (cook); } TxtXmlReturned.Text = (((HttpWebResponse) response) .StatusDescription; SServerResponse = txtXmlReturned.Text + Environment.NewLine; Datastream = response Gateresonsstream (); Reader = new streamrider (datastream); ResponseFromServer = reader.ReadToEnd (); TxtXmlReturned.Text = recover txtXml. Text + feedbackframe server + environment new line; Reader.Close (); Response.Close (); FStream.Close (); Fstream.Dispose (); // ------------------------------------------------ -----------} Other {Message Box. Show ("Size exceeded for size of selected file upload", "file size"); }} Catch (Exceptional Former) {Message Box. Show (ex.Message.ToString (), "Upload Error"); 500 Internal Server Error means there is a problem on server side. You are writing to the customer, see what happens if you go to the URL you are using in the browser.   

No comments:

Post a Comment