---
title: "System.Net.WebRequest - Timeout error"  
description: "System.Net.WebRequest - Timeout error"  
author: "Mark Devid"  
published: 2014-08-28  
updated: 2014-08-28  
canonical: https://www.mindstick.com/forum/2192/system-dot-net-webrequest-timeout-error  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# System.Net.WebRequest - Timeout error

The below piece of [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) is [giving](https://yourviews.mindstick.com/view/80639/regifting-is-far-better-than-giving-away-a-bouquet) [Error Message](https://www.mindstick.com/forum/23174/error-message-the-page-you-are-requesting-cannot-be-served-because-of-the-extension-configuration) : "The [operation](https://www.mindstick.com/forum/33917/how-to-callback-operation-using-delegate-in-c-sharp) has timed out" Error Sourse : at System.Net.httpWebRequest.GetResponse()

```
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            {                /*
Open the requested URL */               
oWebRequest = WebRequest.Create(strURL);               
oWebRequest.Method = "GET";               
oWebRequest.ContentType = "application/xml";                /* Get the stream from the returned web response */               
oStreamReader = new StreamReader(oWebRequest.GetResponse().GetResponseStream());                /* Get the stream from the returned web response */               
oStringBuilder = new StringBuilder();                /*Read the stream a line at a time and place each one into the stringbuilder  */                while ((strLine = oStreamReader.ReadLine()) != null)                {                    /* Ignore blank lines */                    if(strLine.Length > 0)                       
oStringBuilder.Append(strLine);                }               
string[] tempArray = null;               
string[] tempNextArray = null;               
//Split string by semicolon as a separater               
tempArray = Data.SplitString(oStringBuilder.ToString(), new char[] { ';'
});                if(tempArray != null)                {                   
foreach (string invUnits in tempArray)                    {                       
//Split string by '=' as a separater                       
tempNextArray = Data.SplitString(invUnits, new char[] { '=' });                        if (tempNextArray != null && tempNextArray.Length == 2)                       
{                           
switch (tempNextArray[0].ToLower())                           
{                                //case
"msrp":                                //    MSRP =
Data.RemoveDoubleCode(tempNextArray[1]);                                //    break;                                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](https://answers.mindstick.com/qa/43506/please-suggest-the-bathing-date-at-kumbh) what am i [doing wrong](https://answers.mindstick.com/qa/36736/what-are-indians-doing-wrong-on-whatsapp) or [missing](https://answers.mindstick.com/qa/52138/international-missing-children-s-day-2019-was-observed-on)?

## Replies

### Reply by Sumit Kesarwani

Hi mark, try this:\

WebRequest webRequest = WebRequest.Create(requestUri);

webRequest.Credentials = new NetworkCredential(login, password);

WebResponse webResponse = webRequest.GetResponse();

Stream response = webResponse.GetResponseStream();

StreamReader reader = new StreamReader(response);


---

Original Source: https://www.mindstick.com/forum/2192/system-dot-net-webrequest-timeout-error

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
