有没有办法使用 appcmd/netsh 或任何其他命令行实用程序设置 Http.sys
的 UrlSegmentMaxLength
值?
最佳答案
我意识到这是一个老问题,但万一有人偶然发现这个问题,这里有一个 PowerShell 单行代码,它可以创建 key 并设置值或更新现有值。
if ((Get-ItemProperty -Path HKLM:\System\CurrentControlSet\Services\HTTP\Parameters -Name UrlSegmentMaxLength -ErrorAction SilentlyContinue) -eq $null) { New-ItemProperty -Path HKLM:\System\CurrentControlSet\Services\HTTP\Parameters -Name UrlSegmentMaxLength -Value 2048 -PropertyType DWord } else { Set-ItemProperty -Path HKLM:\System\CurrentControlSet\Services\HTTP\Parameters -Name UrlSegmentMaxLength -Value 2048 }
`
至于重启,我发现这个效果很好(不需要重启服务器):
Stop-Service http -Force
Start-Service http
Start-Service IISADMIN
Start-Service W3SVC
关于iis - 从命令行设置 Url 段最大长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20376134/