Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to keep connection alive when using webrequest?
    primarykey
    data
    text
    <p>string strURL = (Request.IsSecureConnection ? "https://website.com/Transaction.asmx" : "http://website.com/wTransaction.asmx");</p> <p>string strCommand = clsMisc.strGetDataFromPage(this, "c", "", PostMethod.BOTH); string strAppCode = clsMisc.strGetDataFromPage(this, "a", "WEBIN", PostMethod.BOTH); string strVenueCode = clsMisc.strGetDataFromPage(this, "v", "", PostMethod.BOTH); long transcationid= long.Parse(clsMisc.strGetDataFromPage(this, "t", "0", PostMethod.BOTH)); string strParam1 = clsMisc.strGetDataFromPage(this, "p1", "", PostMethod.BOTH); string strParam2 = clsMisc.strGetDataFromPage(this, "p2", "", PostMethod.BOTH); string strParam3 = clsMisc.strGetDataFromPage(this, "p3", "", PostMethod.BOTH); string strParam4 = clsMisc.strGetDataFromPage(this, "p4", "", PostMethod.BOTH);</p> <pre><code> StringBuilder sbrPost = new StringBuilder(); string strIPAddress = Request.UserHostAddress.ToString(); if (Request.Headers.ToString().Contains("&amp;X-Forwarded-For=")) { strIPAddress = Request.Headers["X-Forwarded-For"].ToString(); } strAppCode = "|APPCODE=" + strAppCode + "|IPADDRESS=" + strIPAddress + "|"; //strAppCode = "|APPCODE=" + strAppCode + "|IPADDRESS=" + Request.UserHostAddress.ToString() + "|"; sbrPost.Append("&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;"); sbrPost.Append("&lt;soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"&gt;&lt;soap12:Body&gt;&lt;objExecute xmlns=\"http://www.website.com/\"&gt;"); sbrPost.Append("&lt;strAppCode&gt;" + strAppCode + "&lt;/strAppCode&gt;"); sbrPost.Append("&lt;lngTransactionIdentifier&gt;" + lngTransId + "&lt;/lngTransactionIdentifier&gt;"); sbrPost.Append("&lt;strCommand&gt;" + strCommand + "&lt;/strCommand&gt;"); sbrPost.Append("&lt;strParam1&gt;" + strParam1 + "&lt;/strParam1&gt;"); sbrPost.Append("&lt;strParam2&gt;" + strParam2 + "&lt;/strParam2&gt;"); sbrPost.Append("&lt;strParam3&gt;" + strParam3 + "&lt;/strParam3&gt;"); sbrPost.Append("&lt;strParam4&gt;" + strParam4 + "&lt;/strParam4&gt;"); &lt;/objExecute&gt;&lt;/soap12:Body&gt;&lt;/soap12:Envelope&gt;"); string strPost = sbrPost.ToString(); WebRequest objReq = WebRequest.Create(strURL); WebResponse objRes; StreamReader smrRes; byte[] bytData = Encoding.UTF8.GetBytes(strPost); objReq.Method = "POST"; objReq.ContentType = "application/soap+xml"; objReq.ContentLength = bytData.Length; objReq.Timeout = 600000; // 10 minutes Stream objPost = objReq.GetRequestStream(); objPost.Write(bytData, 0, bytData.Length); objPost.Close(); objRes = objReq.GetResponse(); smrRes = new StreamReader(objRes.GetResponseStream()); Response.Write(smrRes.ReadToEnd()); Response.ContentType = "text/xml"; smrRes.Close(); Response.End(); } catch (Exception err) { clsLog.blnLogError(strErrorPage,strErrorMethod, "",err.Message); } } </code></pre> <p>I get an error on da line objPost.Close();.....the unusual error is that when I debug this code line by line slowly using F10 in visual studio 2010...the code works..but when I just run the program or even debug the program fast...it throws an error at that line.. it gives an error that the connection which was expected to be open was closed by the server..</p> <p>HELLLLPPP!!!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload