Join David Gassner for an in-depth discussion in this video Understanding the development web server, part of ASP.NET Essential Training.
- View Offline
When you run a page from within Visual Web Developer, you're actually requesting it from a web server. You're using something called the Development Web Server, a bit of software that's included with both Visual Web Developer and Visual Studio that allows you to test your ASP.NET pages without having to install and configure the full Internet Information Services enterprise-level web server. When you create your first website and your first ASP.NET page and then go to the Debug menu and select Start Without Debugging, you'll see that you're opening the page in your selected web browser. I'm using Internet Explorer. If you look at the URL or the address of the page as it's requested from the web server, you'll see that the URL starts with http://localhost. localhost is the automatic name of a web server that's on your local system. You'll then see this bit of code, colon and then a numeric value. The numeric value is something called a port number. When you run a web page on the internet, typically, you're requesting that web page from port number 80, known as the default HTTP port. Or if you're requesting a page using a prefix of HTTPS, which stands for secure, you're typically using the port in the background of 443. When you use the Development Web Server, by default, the web server assigns a dynamic port number, that is it makes it up at the moment that you start the server. And you can see what the dynamic port number is by looking at the web browser, but you can also see it by going down to the system tray in the lower right-hand corner of the Windows interface. There you'll see a systems tray icon, and if you move the cursor over that icon, you'll once again see an indication of the development server's port number. In most cases, it's fine to use that dynamic port, but in some cases, you might want to set the port explicitly, so you know which port number you'll be using. I'll show you how to do that here. In order to freeze the port number for a particular website, start off in the Properties view. I've gone to the Properties view, which is down in the Lower-right corner, and I'm going to double-click its title bar. That causes it to float. I'll then move it out into the center of the screen and then click and drag to make it a little bit wider. Next, I'll go back to the Solution Explorer, which is still docked on the right, and I'll click on the folder name--that is, the folder which is the name of the website, in this case Hello World. The Properties panel updates and shows the web server properties. Notice that by default, a property called Always Start When Debugging is set to True, and a property called Use Dynamic Ports is set to True as well. I'm going to change that value from True to False, and then I should be able to click into the Port number property. It takes just a moment for it to be activated, so be patient. And then you can type in any port number that isn't otherwise being used on your system. Now, when you set your own port number, you should always use a value that's in the thousands or up. And there's no way to know exactly which port numbers are used on your particular system, but typically, if you use something in the 4,000 range you'll be safe. So I'm going to use a value of 4444. Now, I'm going to save my changes by pressing Ctrl+S. I'll go down to the system tray and I'm going to right-click on the icon for the ASP.NET Development Server, and I'll select Stop, which closes down the web server. Now, I'll move the Properties panel over so I can see the toolbar, and once again, I'll select Debug > Start Without Debugging. The web server is once again started up automatically, but now I'm using the port number 4444. I'll see the value in the web browser and I'll also see it in the system tray icon for the development server. So once again, the purpose of the Development Web Server is to allow you test your pages using a full-blown web server, but without having to go through the process of installing and configuring the full enterprise web server, Internet Information Services. When you deploy your ASP.NET website for production--that is, for use by your users--you'll want to use the full web server. IIS has a lot of tools that the Development Web Server doesn't have, and it's really scalable, meaning it can support a lot more users at the same time than the development server can. But for convenience, you can't beat the Development Server during your initial development phase.
- Storing data with SQL Server
- Using the GridView control to present and edit dynamic data
- Creating a data entry system
- Attaching external CSS files
- Creating pages to log in and authenticate visitors
- Installing Internet Information Services (IIS) on Windows XP and Windows Vista
- Deploying an ASP.NET website on IIS