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 507671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:49:42+00:00 2026-05-13T06:49:42+00:00

I am developing WCF services with basicHttpBinding , these services should be accessible using

  • 0

I am developing WCF services with basicHttpBinding, these services should be accessible using .net 1.1 & .net 2.0, for this purpose I am using basicHttpBinding.
In old ASMX web services I assed one Soap Header (AuthHeader) to authenticate the user every request.

How Can I authenticate in WCF using basicHttpBinding? Any sample Or tutorial will helpfull.

nRk

  • 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-05-13T06:49:42+00:00Added an answer on May 13, 2026 at 6:49 am

    You can use AuthHeader as you did before switching to WCF. Maybe it will be more convinient for you, cause the princples will remain the same.
    The bad thing i see in this solution is a plain text password transfer. Anyway, it’s just another option and you can encrypt/decrypt the password somehow.

    In this case you should implement your own your IDispatchMessageInspector & IClientMessageInspector, like

    [AttributeUsage(AttributeTargets.Class)]
    public class CredentialsExtractorBehaviorAttribute : Attribute, IContractBehavior, IDispatchMessageInspector
    {
        #region IContractBehavior implementation.
    
        public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint,
                                          DispatchRuntime dispatchRuntime)
        {
            dispatchRuntime.MessageInspectors.Add(this);
        }
    
        ... empty interface methods impl skipped ...
    
        #endregion
    
        #region IDispatchMessageInspector implementation.
    
        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            int i = request.Headers.FindHeader("username", "sec");
            if (-1 != i)
            {
                string username = request.Headers.GetHeader<string>("username", "sec");
                ... do smth ...
            }
            return null;
        }
    
        public void BeforeSendReply(ref Message reply, object correlationState)
        {
            return;
        }
    
        #endregion
    }
    

    In a sample i placed to header only username, but you can implement your a class containing username and password and use it instead of string.
    On the client:

    internal class CredentialsInserter : IContractBehavior, IClientMessageInspector
    {
        private string m_username;
    
        public CredentialsInserter(string username)
        {
            m_username = username;
        }
    
        #region IContractBehavior implementation.
    
        ... empty interface methods impl skipped ...
    
        public void ApplyClientBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint,
                                        ClientRuntime clientRuntime)
        {
            clientRuntime.MessageInspectors.Add(this);
        }
    
        #endregion
    
        #region IClientMessageInspector implementation.
    
        public object BeforeSendRequest(ref Message request, IClientChannel channel)
        {
            MessageHeader<string> mh = new MessageHeader<string>(m_username);
            request.Headers.Add(mh.GetUntypedHeader("username", "sec"));
            return null;
        }
    
        public void AfterReceiveReply(ref Message reply, object correlationState)
        {
            return;
        }
    
        #endregion
    }
    

    Then you should place attribute CredentialsExtractorBehaviorAttribute on your service implementation class.

    [CredentialsExtractorBehavior]
    public class DummyService : IDummyService
    {
       ... impl ...
    }
    

    And on the client side you should do the following:

            using (DummyServiceClient c = new DummyServiceClient("TcpEndpoint"))
            {
                c.ChannelFactory.Endpoint.Contract.Behaviors.Add(
                    new CredentialsInserter("_username_"));
                c.DummyMethod();
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been developing a WCF web service using .NET 3.5 with IIS7 and it
The background I'm developing a REST API for a C#.NET web application using WCF.
I'm developing a WCF web services and I use ADO.Net Entities to access database.
The web provides an abundance of tutorials for developing and testing WCF services along
I am developing an app using WF hosted in IIS as WCF services as
I'm developing a program using Windows 7. There are WCF services (soap, rest) that
I am developing a silverlight 3 application using WCF RIA services. I am using
I'm using .NET 3.5 and WCF for developing a server-client application. Binding=BasicHttp. I'm working
I have been developing a WCF project that will expose web services (HTTP-based) that
I'm developing a WCF Service with a custom UserNamePasswordValidator with a basicHttpBinding. This configuration,

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.