Dealing with unwanted port numbers on localhost when debugging in Visual Studio
Posted
by Dan Bailiff
on Stack Overflow
See other posts from Stack Overflow
or by Dan Bailiff
Published on 2010-03-17T21:33:12Z
Indexed on
2010/03/18
1:11 UTC
Read the original article
Hit count: 402
visual-studio-2008
So when I'm trying to debug a project in Visual Studio, I'll often have 1 or more services that I need to call. These services are separate projects and I'll launch them in separate instances of VS. ASP dev server kindly launches them with temporary port numbers attached. This would be fine except for my programs are looking for an IP without a port attached. (Typically it's as simple as "localhost"!) I've coped by using web config settings and changing the xml to use the port number while debugging. This still doesn't always work and occasionally I'll still have to fudge it and insert port numbers as strings in code! UGH! Then I have to remember to undo all the port herding code before deployment...
I want to stop doing this:
string _strBaseURL = String.Format("http://{0}:2277", ConfigurationManager.AppSettings["myservice_ip"].ToString());
What is the best practice here? Am I doomed to port herding while debugging VS apps?
© Stack Overflow or respective owner