![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Unexpected error using WebRequest Hello, I try to post an HTTP message containing an XML document, and I get the following exception : System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to write data to the transport connection: Uma solicitação de envio ou recepção de dados não foi permitida porque o socket não está ligado e (durante o envio num socket de datagrama utilizando uma chamada sendto) não foi fornecido um endereço. ---> System.Net.Sockets.SocketException: Uma solicitação de envio ou recepção de dados não foi permitida porque o socket não está ligado e (durante o envio num socket de datagrama utilizando uma chamada sendto) não foi fornecido um endereço at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.Net.ConnectStream.WriteHeaders(Boolean async) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetRequestStream() at Lafon.Easy.Process.DemandesAuSite.ExecuteDemandeSite() in C:\VSSBASSENS\Easy\Version 2.x\Visual Studio\Lafon\Easy\Process\genereFich.cs:line 9618 It looks as if the underlying socket was closed prematurely. The problem occurs on a WINDOWS XP SP2 (Portuguese), but the same code works fine on other computers with the same operating system. Framework is version 2.0 SP1. The code is executed from within an ASP.NET web application running on IIS. The code is : string _xmlDemande = "<?xml version=\"1.0\" encoding=\"iso-8859-\"?><demServ><dem login=\"" + _sLogin + "\" pass=\"" + _sPass + "\" fich=\"" + _sNomFich + "\" typeRepKo=\"" + sTypeRep + "\" /></demServ>"; byte[] dataToPost = new ASCIIEncoding().GetBytes(_xmlDemande); HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://" + _sAdIp + ":" + _sPortHttp + "/demande.xml"); myRequest.Method = "POST"; myRequest.ContentType = "application/x-www-form-urlencoded"; myRequest.ContentLength = dataToPost.Length; Stream myStream = myRequest.GetRequestStream(); myStream.Write(dataToPost, 0, dataToPost.Length); myStream.Close(); WebResponse myResponse = myRequest.GetResponse(); Stream responseStream = myResponse.GetResponseStream(); ReponseSite rep = new ReponseSite(); XmlSerializer serializer = new XmlSerializer(typeof(ReponseSite)); rep = (ReponseSite)serializer.Deserialize(responseStream); responseStream.Close(); myResponse.Close(); myStream.Close(); Does somebody have any explanation ? -- Olivier GIL LAFON SA |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| something unexpected error | Live Mail | |||
| Unexpected Error: Fax Can't be received because of an unexpected e | Vista print fax & scan | |||
| unexpected error | Vista mail | |||
| Net.WebRequest.Create objects GetResponse method returns -1.. why? | .NET General | |||