views:

18

answers:

3

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.

A: 

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.

Oded
+1  A: 

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.

Francisco
A: 

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.

Iain