Hi WebGurus,
I have a WCF service hosted within a asp.net mvc2 application. The application uses ADFS as authentication process. Now I am trying to check the status of the WCF service (i.e running and up or not) using the below code without authenticating against the application:
Site URL :
https://demoworks.com/ WCF Address:
https://demoworks.com/ChartsService.svc Based on the above details _address =
https://demoworks.com/ChartsService.svc **Code:**
var passed = Utility.ConnectToWebService(_address, out statusCode, out responseText);
public static bool ConnectToWebService(Uri address, out System.Net.HttpStatusCode statusCode, out string responseText)
{
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; };
System.Net.HttpWebRequest request =
(System.Net.HttpWebRequest)System.Net.WebRequest.Create(address);
// Set some reasonable limits on resources used by this request
request.MaximumAutomaticRedirections = 4;
request.MaximumResponseHeadersLength = 4;
// use default credentials
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
statusCode = response.StatusCode;
// Get the stream associated with the response.
System.IO.Stream receiveStream = response.GetResponseStream();
// Pipes the stream to a higher level stream reader with the required encoding format.
System.IO.StreamReader readStream = new System.IO.StreamReader(receiveStream, System.Text.Encoding.UTF8);
responseText = readStream.ReadToEnd();
response.Close();
readStream.Close();
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return false; };
return statusCode == System.Net.HttpStatusCode.OK;
}
While debugging the code I see that the ResponseUri value of the response object has ADFS url embedded to it which shows that it is going to ADFS to authenticate.
Can anyone help me to show the best way to bypass the ADFS authentication while checking the WCF service status?
Thanks & Regards,
Santosh Kumar Patro
santosh kumar patro