Asp.net 如何查找URL注册(非预订)?

Asp.net 如何查找URL注册(非预订)?,asp.net,windows,http,tcp,web-development-server,Asp.net,Windows,Http,Tcp,Web Development Server,是否有windows命令列出持有特定URL注册的应用程序的进程ID和名称 我在下面的URL名称空间下注册的应用程序之后 http://localhost:55987/ 我知道URL预订可以使用 netsh http show urlacl 保留声明: Reserved URL : http://localhost:55987/ User: \Everyone Listen: Yes Delegate: No

是否有windows命令列出持有特定URL注册的应用程序的进程ID和名称

我在下面的URL名称空间下注册的应用程序之后

http://localhost:55987/
我知道URL预订可以使用

netsh http show urlacl

保留声明:

 Reserved URL            : http://localhost:55987/
     User: \Everyone
         Listen: Yes
         Delegate: No
         SDDL: D:(A;;GX;;;WD)

但是如何查找在保留URL命名空间下进行的注册?

您可以使用以下命令查找已注册URL的processId:

netsh http show servicestate view=requestq verbose=no
它将返回一个如下所示的表:

    Request queue name: Request queue is unnamed.
        Version: 2.0
        State: Active
        Request queue 503 verbosity level: Basic
        Max requests: 1000
        Number of active processes attached: 1
        Process IDs:
            3604
        URL groups:
        URL group ID: F100000040000003
            State: Active
            Request queue name: Request queue is unnamed.
                Number of registered URLs: 1
                Registered URLs:
                    HTTP://+:8022/
            Server session ID: F200000020000007
                Version: 2.0
                State: Active
    Request queue name: Request queue is unnamed.
        Version: 2.0
        State: Active
        Request queue 503 verbosity level: Basic
        Max requests: 1000
        Number of active processes attached: 1
        Process IDs:
            3604
        URL groups:
        URL group ID: D400000040001E9C
            State: Active
            Request queue name: Request queue is unnamed.
                Number of registered URLs: 1
                Registered URLs:
                    HTTP://+:3799/API
            Server session ID: D6000000200013C1
                Version: 2.0
                State: Active
我还制作了一个powershell函数,它解析这个输出以返回一个对象列表

结果样本:

ProcessId                               ControllerProcessId                     RegisteredUrl
---------                               -------------------                     -------------
1860                                                                            HTTP://+:8022/
1020                                                                            HTTPS://+:5986/WSMAN/
函数解析-HttpSysReqQueue(){
[string[]$rawHttpSysQueue=netsh http show servicestate view=requestq verbose=no
$URL=@()
$output=@()
$recordIsOpen=$false
$index=0
$rawHttpSysQueue | ForEach对象{
$line=$_
#是否是新请求队列记录的开始。
$newRecordToken=“请求队列名称”
if($line.StartsWith($newRecordToken)){
$recordIsOpen=$true
$index++;返回
}
#我们正在遍历请求队列记录。
如果($recordIsOpen){
#获取进程ID
if($line.Contains(“进程ID:”)){
$rawPid=$rawHttpSysQueue[$index+1]
如果($rawPid.Trim()-匹配“^\d+$”){
$processId=$rawPid.Trim()
}否则{
$processId=$null
}
$index++;返回
}
#获取控制器进程ID(通常为IIS)
if($line.Contains(“控制器进程ID:”)){
$controllerProcessId=$line.Split(“:”[1].Trim()
$index++;返回
}
#从当前记录读取所有注册的URL。
如果($line.Contains(“注册URL:”)){
$urlLineIndex=$index+1
而($rawHttpSysQueue[$urlLineIndex].Trim().StartsWith(“HTTP://”)或$rawHttpSysQueue[$urlLineIndex].Trim().StartsWith(“HTTPS://”)则{
$URL+=$rawHttpSysQueue[$urlLineIndex].Trim()
$urlLineIndex++
}
#将记录添加到输出列表。
$url | ForEach对象{
$output+=新对象PSObject-属性@{
ProcessId=$ProcessId
RegisteredUrl=$_
ControllerProcessId=$ControllerProcessId
}
}
已经读取了这个请求队列中的所有URL,考虑记录关闭。
$processId=$null
$controllerProcessId=$null
$URL=@()
$recordIsOpen=$false
}
}
美元指数++
}
返回$output
}