I want to add authentication as NetworkCredential but I do not know how do I set the authentication
var binding = new BasicHttpBinding();
var endpoint = new EndpointAddress(new Uri(string.Format("http://{0}:5050/Service.svc", Environment.MachineName)));
var channelFactory = new ChannelFactory<ISampleService>(binding, endpoint);
var serviceClient = channelFactory.CreateChannel();
You can inspire in my code. It took me some time and some investigation. Remember, service contract interface is implemented by controller, I did not find any other way to put the service request to http pipeline. Due to this configuration I can run REST and SOAP branches on one code.
In Startup.cs:
Then create class for handling basic authentication: