Microsoft.Web.Administration.Binding.ToString C# (CSharp) Method

ToString() public method

public ToString ( ) : string
return string
        public override string ToString()
        {
            return string.Format(
                "{0}:{1}:{2}",
                this.EndPoint.Address.AddressToDisplay(),
                EndPoint.Port,
                Host.HostToDisplay());
        }

Usage Example

Example #1
0
        public static string CleanUpSni(this Binding binding)
        {
#if !IIS
            if (!binding.GetIsSni())
            {
                return(string.Empty);
            }
#endif
            try
            {
                var hash = binding.CertificateHash == null ? string.Empty : Hex.ToHexString(binding.CertificateHash);
                // remove sni mapping
                using (var process = new Process())
                {
                    var start = process.StartInfo;
                    start.Verb            = "runas";
                    start.UseShellExecute = true;
                    start.FileName        = "cmd";
                    start.Arguments       =
                        $"/c \"\"{CertificateInstallerLocator.FileName}\" /h:\"{hash}\" /s:{binding.CertificateStoreName}\" /i:{AppIdIisExpress} /o:{binding.EndPoint.Port} /x:{binding.Host}";
                    start.CreateNoWindow = true;
                    start.WindowStyle    = ProcessWindowStyle.Hidden;
                    process.Start();
                    process.WaitForExit();

                    if (process.ExitCode != 0)
                    {
                        return("Remove SNI certificate failed: access is denied");
                    }

                    return(string.Empty);
                }
            }
            catch (Win32Exception ex)
            {
                // elevation is cancelled.
                if (ex.NativeErrorCode != NativeMethods.ErrorCancelled)
                {
                    RollbarLocator.RollbarInstance.Error(ex, new Dictionary <string, object> {
                        { "native", ex.NativeErrorCode }
                    });
                    return($"Remove SNI certificate failed: unknown (native {ex.NativeErrorCode})");
                }

                return("Remove SNI certificate failed: operation is cancelled");
            }
            catch (NullReferenceException ex)
            {
                RollbarLocator.RollbarInstance.Error(ex, new Dictionary <string, object> {
                    { "binding", binding.ToString() }, { "endpointNull", binding.EndPoint == null }
                });
                return($"Remove SNI certificate failed: unknown ({ex.Message})");
            }
            catch (Exception ex)
            {
                RollbarLocator.RollbarInstance.Error(ex);
                return($"Remove SNI certificate failed: unknown ({ex.Message})");
            }
        }
All Usage Examples Of Microsoft.Web.Administration.Binding::ToString