How to set WinRT Post HttpWebRequest timeout in windows 8.1 store app RRS feed

  • Question

  • Hello,

    I have gone through this post but there is no solution for my question.


    but I am still not clear about how to set timeout in windows 8.1 Httpwebrequest post method..

    in previous post then mention something else which is not relevant to my problem..

    I have HttpWebRequest method as a Post type and I am looking defualt timeout is there or not..?

    if it is not there then how could I can set timeout..

    her is my sample method..

            /// <summary>
            /// Post method for request and responce for every method 
            /// </summary>
            /// <param name="model">Class objcet</param>
            /// <param name="methodName">method name for e.g essayFeedbackRequest</param>
            /// <returns></returns>
            public static async Task<string> HttpWebRequestResponseGetLibraryProgress(object model, string methodName)
                string responseResutl = string.Empty;
                    var webRequest = (HttpWebRequest)WebRequest.Create(GlobalData.PedAPI + methodName);
                    webRequest.Method = "POST";
                    webRequest.ContentType = "application/json; charset=utf-8";
                    var Serialized = SerializeDeserialize.Serialize(model);
                    string finalSerialized = Serialized;
                    using (StreamWriter sw = new StreamWriter(await webRequest.GetRequestStreamAsync()))
                    HttpWebResponse httpWebResponse = await webRequest.GetResponseAsync() as HttpWebResponse;
                    using (StreamReader sr = new StreamReader(httpWebResponse.GetResponseStream()))
                        if (httpWebResponse.StatusCode != System.Net.HttpStatusCode.Accepted)
                            string messageresult = String.Format("POST failed. Received HTTP {0}", httpWebResponse.StatusCode);
                        responseResutl = sr.ReadToEnd();
                    return responseResutl;
                catch (Exception ex)
                    if (ex.Message.Contains("The request was aborted: Could not create SSL/TLS secure channel."))
                        goto callAgain;
                    throw ex;

    thank you..

    Jitendra Jadav

    Wednesday, December 10, 2014 10:48 AM