Tip: Use specific port number when hosting WCF service in Cassini Web Server

When you are hosting a WCF service in Visual Studio, a Cassini Web Server will spin up and assign a random port number, e.g. http://localhost:61447/MyService. If you add a Service Reference, it will use that port number currently assigned by Cassini. This is all good until you stop the Cassini Web Server, or restart VS IDE. Where did my old port number go???

The problem I have with this is that it gets meddlesome very quickly. Of course you can host your WCF on IIS on your development machine, but if not there is another option. You can assign a Specific Port Number in your VS project Settings. Right click on your WCF Service Project and select Properties. Click the Web tab on the left, and assign a specific port number of your choice. Problem solved! Just make sure you don’t attempt to host different services on the same port number.


Share this post:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: