URI已存在注册-如何以编程方式检查/删除注册? [英] A registration already exists for URI - How to programmatically check / remove registration?

查看:118
本文介绍了URI已存在注册-如何以编程方式检查/删除注册?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将在服务结构中托管我的WCF服务. WCF服务之一在启动后在端口上启动HttpSelfHostServer.我有时会收到错误:

I am hosting my WCF services in service fabric. One of the WCF service starts a HttpSelfHostServer on a port after startup. I sometimes gets the error:

已经存在URI' http://localhost:10503/'的注册. 在System.Runtime.AsyncResult.End [TAsyncResult](IAsyncResult结果)处 在System.ServiceModel.Channels.CommunicationObject.EndOpen(IAsyncResult结果) 在System.Web.Http.SelfHost.HttpSelfHostServer.OpenListenerComplete(IAsyncResult结果)

A registration already exists for URI 'http://localhost:10503/'. at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) at System.ServiceModel.Channels.CommunicationObject.EndOpen(IAsyncResult result) at System.Web.Http.SelfHost.HttpSelfHostServer.OpenListenerComplete(IAsyncResult result)

在服务架构中,我认为框架可能会产生多种服务.我想知道是否有任何方法可以通过编程方式检查端口并检测是否有注册的服务并自动将其删除?

In service fabric, I think there could be multiple services spun up by the framework. I am wondering if there is any way to programmatically check the port and detect there is a service registered with it and remove it automatically?

推荐答案

https://docs.microsoft.com/en-us/windows/win32/http/show-urlacl
Netsh http show Urlacl command is able to help us to detect the reserved URl. But as you know, we need to elevate the permission to an administrator, then delete or add the entry for the specifical users and accounts(The administrator account can directly remove the occupation and use the reserved URL).

Netsh http add urlacl url=https://+:80/MyUri user=DOMAIN\user 
delete urlacl url=https://+:80/MyUri

如果以编程方式完成,则需要以管理员身份执行delete命令,该管理员可以直接删除职业并使用保留的URL.因此,我认为这不可行.
随时让我知道是否有什么可以帮助您的.

If it is accomplished programmatically, we need to execute the delete command as an administrator, who can directly remove the occupation and use the reserved URL. Therefore, I don't think it is feasible.
Feel free to let me know if there is anything I can help with.

这篇关于URI已存在注册-如何以编程方式检查/删除注册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆