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.
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.
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.
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:
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>False</AutoAssignPort>
<DevelopmentServerPort>1665</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>
</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
As simple as that.
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.