Welcome to MSDN Blogs Sign in | Join | Help

How to set the default port for a File System web in Visual Studio 2005

One of the questions I'm often asked is how to set the default port for a File System web in Visual Studio 2005.

New is Visual Studio 2005 is a built in development web server for testing the web applications your developing with out having IIS installed on the dev machine. The server is named WebDev.WebServer.exe. It gets installed by VS into the Framework version directory. If you run this application without any argument you will get this usage screen.



When you create a new website in VS 2005, you pick how the site will be accessed, for example it can be a File System, HTTP, or FTP site. 



If you pick File System, this will tell VS that it should use WebDev.WebServer.exe to serve up the application. You’ll notice that one of the command line arguments for WebDev.WebServer.exe is /port: , yet at no time was the user prompted for a port number. What port is it using and how can I override that setting?

VS 2005 is dynamically getting the next avail ephemeral port on the machine. This is done via a call the WinSock API. 

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/bind_2.asp

"For TCP/IP, if the port is specified as zero, the service provider assigns a unique port to the application with a value between 1024 and 5000."

btw: It is possible to get a automatically assigned port larger than 5000 by changing MaxUserPort under HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

http://www.microsoft.com/resources/documentation/Windows/2000/server/reskit/en-us/Default.asp?url=/resources/documentation/Windows/2000/server/reskit/en-us/regentry/58791.

VS will store the dynamically computed port in the solution file and reuse it each time the website is opened with that solution. Even though VS has stored this port in the solution file, it’s possible that VS with change the port again when launching WebDev.WebServer.exe if that port is in use by a different application. Fortunately VS is smart enough to not dynamically change the port if you have another project in the same solution with a Web Reference to that Website project. Generally speaking the developer should not have to worry about these dynamically assigned ports.

However, what if the other application is not in the same solution and you just want to fix the port used and never have it changed by VS. How can you do this?

Once you’ve opened a File System Web you can change how VS assigns port numbers. To do this select the root node of your site, and press F4 to bring up the properties tool window. Within this window you’ll see a category of parameters for the Development Web Server. Change the “Use dynamic ports” to False then set the port number to any value you like.



Btw: you’ll notice that the dynamic port assigned in this example is 12988, well beyond the 5000 limit we’d expect. That is because on the machine I used MaxUserPort was set to 65534.

Now in this example I’ve change the dynamic port to False and set the port number to 8080.



These settings will be persisted in the solution file and never changed by VS. Be aware that if you add the same website to a different solution it will default to using a dynamic port when run in that solution. These settings are specific to the solution containing that website.

I’d like to call attention to one other issue that can happen when calling Web Services hosted by WebDev.WebServer.exe. If NTLM authentication is enabled for WebDev.WebServer.exe, you may need to manually set UseDefaultCredentials = True in the client proxy.

You can check the NTLM setting in the project properties, Start Options.



If set, you may need to set the UseDefaultCredentials property to True in the client proxy calling that service. This should have been automatically added to the proxy during code generation but if you’re getting a “401 Authentication failed” error then you’ll need to set this property when calling a web service hosted by WebDev.WebServer.

Dim ls As New localhost.Service
ls.UseDefaultCredentials = True
MsgBox(ls.HelloWorld())

As you can see there are a number of ways to change how VS launches WebDev.WebServer.exe. By default you should not have to change anything but if you need to, you can.

Hope, this helps,
Brad

Posted by BradleyB | 1 Comments

A week with the ASP.Net Support Team

For the next few weeks I’ll be participating in Microsoft’s Frontline program.  It’s a great opportunity for me to get out and meet with customers using our products.  This week I was down in Los Colinas TX at Microsoft Customer Support Services group.  These guys are awesome.  It’s unbelievable what their able to diagnose from the sketchy information they get.  One of their engineers was explaining a customer who could only communicate a memory dump over the phone.  Talk about tough….  I spent most of my time with the ASP.Net support team.  These engineers are experts at diagnosing problems in deployed applications.  They often don’t get the luxury having a repro in house that they can attach a debugger to and catch the failure.  More often than not they collect dump files from the customer site and perform a post-mortem analysis.  They’re like forensic CSI experts.  They provide support 24x7.  While I was there I saw everything from simple configuration issues to complex hangs or memory leaks in distributed systems.

 

There were some general issues I saw repeatedly.  One of which was excessive memory consumption due to misuse of strings.  There is a great article on MSDN covering performance http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenetchapt06.asp

 

Checkout the section on strings.  In short don’t use concatenation += with Strings to build up a response page.  Consider using Response.Write() directly or using StringBuilder to build up large strings.  StringBuild is in the System.Text namespace.  You’d be surprised how much of the overall memory consumption is in strings.

 

They’ve developed some awesome tools to help narrow down the problems customers face.  More often than not it is a problem somewhere in the application or in a 3rd party component.  And yes, occasionally in ASP.Net.

 

Many of the techniques they use are documented on MSDN.  Check out this article:  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/DBGch02.asp

 

Posted by BradleyB | 3 Comments

Joining the Blogosphere

With the release of Visual Studio Whidbey Beta2 I though it would be a good time to join the blogosphere.  

 

If you don’t already know the Beta2 drop can be found at:  

 

http://msdn.microsoft.com/getthebetas/

http://lab.msdn.microsoft.com/vs2005/get/

 

So who am I and what do I work on? 

 

My name is Bradley Bartz aka bradleyb@microsoft.com  I’m a developer working on Visual Web Developer for ASP.Net 2.0.  If you haven’t checked it out yet, what are you waiting for?  You’ll be surprised how much functionality is in the express editions.

 

I work on what is known as the project system.  It’s the behind the scenes pluming that mimics the ASP.Net runtime behavior at design time.   Visual Web Developer is in fact an add-in package for Visual Studio.  Our primary objective in Whidbey was to fully leverage the ASP.Net platform creating the best development experience anywhere for ASP.Net.  You be the judge.  I’ll post more on some of the specific features later.

Posted by BradleyB | 0 Comments
 
Page view tracker