diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/UDSBindingTests.cs b/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/UDSBindingTests.cs index c6a68c6c713..ab9add0b076 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/UDSBindingTests.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/UDSBindingTests.cs @@ -75,13 +75,9 @@ public void WindowsAuth() System.ServiceModel.UnixDomainSocketBinding binding = new UnixDomainSocketBinding(System.ServiceModel.UnixDomainSocketSecurityMode.Transport); binding.Security.Transport.ClientCredentialType = System.ServiceModel.UnixDomainSocketClientCredentialType.Windows; - var uriBuilder = new UriBuilder() - { - Scheme = "net.uds", - Path = UDS.GetUDSFilePath() - }; + var uri = new Uri("net.uds://" + UDS.GetUDSFilePath()); factory = new System.ServiceModel.ChannelFactory(binding, - new System.ServiceModel.EndpointAddress(uriBuilder.ToString())); + new System.ServiceModel.EndpointAddress(uri)); channel = factory.CreateChannel(); ((IChannel)channel).Open(); string result = channel.Echo(testString); diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketChannelFactory.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketChannelFactory.cs index 41f9651c864..e99e262579e 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketChannelFactory.cs +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketChannelFactory.cs @@ -40,7 +40,7 @@ protected override TChannel OnCreateChannel(EndpointAddress address, Uri via) { if(address.Identity == null) { - var hostIdentity = new DnsEndpointIdentity(address.Uri.Host ?? "localhost"); + var hostIdentity = new DnsEndpointIdentity(string.IsNullOrEmpty(address.Uri.Host) ? "localhost" : address.Uri.Host); var uriBuilder = new UriBuilder(address.Uri); uriBuilder.Host = null; address = new EndpointAddress(uriBuilder.Uri, hostIdentity,address.Headers.ToArray());