Мой сетевой администратор не работает и отказал в доступе к производственному серверу.
Есть ли способ, которым я могу программно добавить заголовок хоста в коде с VB?
Я пытался поместить этот код в код позади главной страницы, но DirectoryEntry - Type 'DirectoryEntry' is not defined.
Private Shared Sub AddHostHeader(ByVal websiteID As System.Nullable(Of Integer), ByVal ipAddress As String, ByVal port As System.Nullable(Of Integer), ByVal hostname As String)
Using directoryEntry = New DirectoryEntry("IIS://localhost/w3svc/" & websiteID.ToString())
Dim bindings = directoryEntry.Properties("ServerBindings")
Dim header = String.Format("{0}:{1}:{2}", ipAddress, port, hostname)
If bindings.Contains(header) Then
Throw New InvalidOperationException("Host Header already exists!")
End If
bindings.Add(header)
directoryEntry.CommitChanges()
End Using
End Sub
У кого-нибудь есть простой ответ?