adsense

Thursday, April 25, 2019

document ready not fired after post back

jQuery DOM ready tends to break if you are still working with update panels and the actual reason for that can caused by many things.

For me, it was calling DOM ready in Sys.Application.add_load(function); as displayed below.

 <script type="text/javascript">
         
Sys.Application.add_load(DomLoad);

function DomLoad() {
        $(function() {
                   //more code
        });
 }

 </script>

This also can be useful if you want to add multiple page loads scripts.

Read the following stack overflow post for more discussion on the same topic.

Cheers,
Samitha

Tuesday, April 16, 2019

TLS 1.2 suport in .Net 4.5 or above

Even thought Net 4.5 or above supports TLS 1.2, .Net default protocol is TLS 1.0. It is recommended to set the SecurityProtocol before any WebRequest calls.

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12;

var url = "https://www.gmail.com";
var request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";

Setting SecurityProtocol before any WebRequest calls will make sure that response will not get following error when getting the response.

"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."