在具体端口中部署 .NET Web 服务
我想始终在同一端口部署或发布基于 .NET 的 Web 服务。
我可以直接在我的代码中执行此操作(以编程方式说话)吗?
谢谢。
I would like to deploy or publish my .NET based web service always at the same port.
Can I do this directly in my code (programmatically talking)?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为更好的解决方案可能是编辑与 Web 服务相关的项目属性。在 Web 部分,您可以编辑要发布的具体端口。
另一种方法是编辑文件 .csproj。它看起来像一个 xml,您可以在其中找到并编辑以下几行:
就这么简单。
I think a better solution could be to edit the project propietries related to the web service. At the Web section you can edit the concrete port to publish.
Another way to do that is to edit the file .csproj. It looks like a xml where you can find and edit the following lines:
As simple as that.
端口是在 Web 服务器上定义的,因此您需要创建一个安装程序,始终使用该端口为其设置 Web 服务和 IIS 站点。
Ports are defined on the web server, so you need to create an installer that always sets the web services and the IIS site for them with that port.
如果您使用 Casssini (asp.net WebServer),您可以在 c# 项目设置中每次更改设置使用相同的端口,如果您使用 IIS,可以在网站的 bingings 或主机标头中进行设置。
If you are using Casssini (asp.net WebServer), you change the settings use the same port every time within the c# project settings, if you using IIS can set this in the bingings or host headers of the website.