The following code snippet gives
the error message: "Operation completed" Sourse error: at System.Net.httpWebRequest.GetResponse ()
This method calls the URL and receives the response object.
NOTE. All this works fine at my end ... but when I send the same code to production .. it shows the time of no errors
public GetUpdatedInventoryUnitValues(Vehicle aeVehicle)
{
WebRequest oWebRequest = null;
StringBuilder oStringBuilder = null;
StreamReader oStreamReader = null;
dcDealerDetails = new Dictionary<string, string>();
MSRP = string.Empty;
NetPrice = string.Empty;
string strLine = string.Empty;
string strURL = GetUpdatedInventoryUnitValues.GetFormattedURL(aeVehicle);
try
{
oWebRequest = WebRequest.Create(strURL);
oWebRequest.Method = "GET";
oWebRequest.ContentType = "application/xml";
oStreamReader = new StreamReader(oWebRequest.GetResponse().GetResponseStream());
oStringBuilder = new StringBuilder();
while ((strLine = oStreamReader.ReadLine()) != null)
{
if (strLine.Length > 0)
oStringBuilder.Append(strLine);
}
string[] tempArray = null;
string[] tempNextArray = null;
tempArray = Data.SplitString(oStringBuilder.ToString(), new char[] { ';' });
if (tempArray != null)
{
foreach (string invUnits in tempArray)
{
tempNextArray = Data.SplitString(invUnits, new char[] { '=' });
if (tempNextArray != null && tempNextArray.Length == 2)
{
switch (tempNextArray[0].ToLower())
{
case "netprice":
NetPrice = Data.RemoveDoubleCode(tempNextArray[1]);
break;
}
}
}
}
}
catch (Exception ex)
{
ErrorLog.ErrorMessage = ErrorLog.Separator;
ErrorLog.ErrorMessage = "Exception during posting data to another application .";
ErrorLog.ErrorMessage = "ERROR MESSAGE : " + ex.Message;
ErrorLog.ErrorMessage = "ERROR SOURCE: " + ex.StackTrace.ToString();
}
finally
{
if (oStreamReader != null)
{
oStreamReader.Close();
}
if (oWebRequest != null)
{
oWebRequest = null;
}
}
}
Please suggest what am I doing wrong or not enough?
source
share