如何在 IIS 8 (Windows 8) 中修改已配置站点中的现有绑定?我正在尝试通过命令提示符来执行此操作。
我可以通过以管理员模式运行的命令提示符添加新绑定:
> C:\Windows\System32\inetsrv>appcmd set site /site.name:test /+bindings.[protocol='http',bindingInformation='*:80:mitest']
在命令提示符下,我使用:
> C:\Windows\System32\inetsrv>appcmd set site "test" /?
要查看 SET Binding 选项,并且不存在作为“SET Binding BY BINDING ID”的命令。
通过 C# 代码我使用:
string windir = Environment.GetEnvironmentVariable("windir");
string comando = windir +"\\System32\\inetsrv\\appcmd.exe set site /site.name:test /+bindings.[protocol='http',bindingInformation='*:80:mitest']";
System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + comando);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
procStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
string result = proc.StandardOutput.ReadToEnd();
Console.WriteLine(result);
Debug.WriteLine(result);
我得到错误:“由于权限不足,无法读取配置文件”
但我不能通过命令修改。而且我无法通过代码为下一步创建绑定尝试修改它。