Mugu
Mugu

Reputation: 133

how to set timeout for httpwebrequest in C# , WinRT

I would like to set a timeout value for httpwebrequest in my C# WinRT code. But httpwebrequest is not available in WinRT. so how please let me know how to set the timeout value for the HttpWebRequest.

Upvotes: 1

Views: 1674

Answers (2)

sayah imad
sayah imad

Reputation: 1553

to set timeout to your webrequest you need to set HttpWebRequest.Timeout and it's all .

HttpWebRequest myHttpWebRequest = (HttpWebRequest) WebRequest.Create("your url");
myHttpWebRequest.Timeout = 1000 ;

Upvotes: 0

Falanwe
Falanwe

Reputation: 4744

Use the HttpClient class to make your request. It has a TimeOut property you can set to your liking.

You can also use the HttpWebRequest class, and it also have a TimeOut property.

In most cases, HttpClient is the way to go, as it is easier to use and you don't need the level of customization the HttpWebRequest provides.

Upvotes: 1

Related Questions