1

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.

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

so you mean to say that there is no way to set timeout if I use HttpWebRequest ?
I'm sorry, i took for granted your affirmation that "httpwebrequest is not available in WinRT". Turns out it is available. I edited my answer accordingly. Anyway, in most cases, use HttpClient: it's far easier to use and can make multiple requests if need be.
0

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 ; 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.