Wednesday, March 19, 2014

How to enable WCF tracing to debug weird problem?

Got a weird WCF timeout exception
The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue
The read operation failed, see inner exception.

After tried all of settings related to timeout, decided to enable WCF tracing to see what exactly happened on server side.

Found one serialization exception in the log, solved the problem.


Put following setting to enable WCF tracing:

    
        
            
                
                    
                
            
            
                
                    
                
            
            
                
                    
                
            
            
                
                    
                
            
            
                
                    
                
            
        

        
            
        
    


http://msdn.microsoft.com/en-us/library/ms733025.aspx



How to format phone number in C#

String.Format("{0:###-###-####}", double.Parse("1234567890"))

How to valid phone by Knockout Validation plugin ?

Add Knockout Validation reference into project from
https://github.com/ericmbarnard/Knockout-Validation

    self.Telephone = ko.observable("").extend({
        required: true,
        pattern: {
            message: '*Invalid Phone Number. (Format: 999-999-9999)',
            params: /\d{3}-\d{3}-\d{4}/
        }
    });