Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8807371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:21:10+00:00 2026-06-14T02:21:10+00:00

Hello everyone I’m a beginner in MVC3. My question is about using class. I’m

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:21:11+00:00Added an answer on June 14, 2026 at 2:21 am

    I assume that both service classes are derived from same interface, eg. IServices, then:

    private void AssignCredentials(IServices services)
    {
       services.ClientCredentials.UserName.UserName = "service_test";
       services.ClientCredentials.UserName.Password = "..";
       services.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;
    }
    

    and in your base method call AssignCredentials method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello everyone i have an question about firefox add-on: How i can get the
Hello everyone I want to ask a question about including guards in C programming.
Hello everyone, I'm developing a photo sharing web site using the CodeIgniter PHP framework
I solved this question my own. The filename was wrong lolz. Hello everyone! I'm
Hello everyone I'm a beginner in MVC3 so I'm trying to use pdf reporting
Hello everyone don't know why this code works on windows but not on linux
Hello everyone I am getting this exception: The magic number in GZip header is
Hello everyone I am trying to resize an image of 700kb with imagecreatefromjpeg. This
hello everyone im trying to create this tweak that copies a file from one
Hello everyone. I'm using Silverlight webbrowser control, and I'm having some problems with that.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.