Hello everyone I’m a beginner in MVC3. My question is about using class. I’m using web services to get parameter at this point I have no problem but my problem is I’m defining every connection in each controller method again and again so is there any shorcut ?
Here is an example:
public ActionResult BeyanListe()
{
Services_building client = new Services_built();
Services client_service = new Services();
client_service.ClientCredentials.UserName.UserName = "service_test";
client_service.ClientCredentials.UserName.Password = "..";
client_service.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;
client.ClientCredentials.UserName.UserName = "service_test";
client.ClientCredentials.UserName.Password = "..";
client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;
return View()
}
As you can see top I have declared two times for clientcredentials
I assume that both service classes are derived from same interface, eg. IServices, then:
and in your base method call AssignCredentials method.