Monday, November 21, 2016

webclient timeout exception c#

HI All,

Please find the below code to Overcome Timeout Issue from WebClient

         /// <summary>
        /// MyWebClient to increase Timeout
        /// </summary>
        public class MyWebClient : WebClient
        {
            //time in milliseconds
            private int timeout;
            public int Timeout
            {
                get
                {
                    return timeout;
                }
                set
                {
                    timeout = value;
                }
            }

            public MyWebClient()
            {
                this.timeout = 300000;
            }

            public MyWebClient(int timeout)
            {
                this.timeout = timeout;
            }

            protected override WebRequest GetWebRequest(Uri address)
            {
                var result = base.GetWebRequest(address);
                result.Timeout = this.timeout;
                return result;
            }
        }

Call the Above Code using below

using (var client = new MyWebClient())
 {
client.Headers.Add(username and Password); // Replace "username and Password" with your username and Password
client.Headers[HttpRequestHeader.ContentType] = "application/json";
var result = client.UploadString(URL, "POST", JSONData); // Replace "URL" with your Service URL and "JSONData" with your JSON Output Data
}


Day 11 - Customizing Option Sets Dropdown Fields with JavaScript

  In this Blog, we will see how to Customizing Option Sets Dropdown Fields with JavaScript label1 = formContext.getAttribute( "bosch_op...