Set4u.Biz - Tips and Tricks in a world of Mix

Loading

Archives November 2010

TrustAllCertificatePolicy – Handles a call to a web service via SSL that does not have a valid server certificate

  /// <summary>     /// Handles a call to a web service via SSL that does not have a valid server certificate     /// </summary>     /// <example>     /// locate this code at the authorization class before validating the web service     /// System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();     /// </example>     public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy     {         public TrustAllCertificatePolicy()         { }          public bool CheckValidationResult(ServicePoint sp,          X509Certificate cert, WebRequest req, int problem)         {             return true;         }     }

Read more
Check URL Availability

Private WebServiceStatusCode As String Public Function ConnectionAvailable(ByVal strServer As String) As Boolean Try Dim reqFP As HttpWebRequest = DirectCast(HttpWebRequest.Create(strServer), HttpWebRequest) Dim rspFP As HttpWebResponse = DirectCast(reqFP.GetResponse(), HttpWebResponse) If HttpStatusCode.OK = rspFP.StatusCode Then ‘ HTTP = 200 – Internet connection available, server online WebServiceStatusCode = rspFP.StatusCode.ToString() rspFP.Close() Return True Else ‘ Other status – Server or connection not available WebServiceStatusCode = rspFP.StatusCode.ToString() rspFP.Close() Return (False) End If Catch generatedExceptionName As WebException ‘ Exception – connection not available WebServiceStatusCode = generatedExceptionName.Message Return False End Try End Function

Read more
Prism – module composition with WPF and Silverlight – download and build dll’s

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=387c7a59-b217-4318-ad1b-cbc2ea453f40&displaylang=en download CompositeApplicationGuidance-Oct2009.exe run with destination folder. Enter the dest folder –> CAL –> open sln –> build –> get the dll’s. Nessasary dll’s are – “..\CAL\Silverlight\Composite.UnityExtensions\Bin\Debug” Microsoft.Practices.Composite.dll Microsoft.Practices.Composite.Presentation.dll Microsoft.Practices.Composite.UnityExtensions.dll…

Read more