Last month we released the VS 2010 Service Pack 1 (SP1) Beta. You can learn more about the VS 2010 SP1 Beta from Jason Zander’s two blog posts about it, and from Scott Hanselman’s blog post that covers some of the new capabilities enabled with it.
You can download and install the VS 2010 SP1 Beta here.
Earlier this summer I blogged about IIS Express. IIS Express is a free version of IIS 7.5 that is optimized for developer scenarios. We think it combines the ease of use of the ASP.NET Web Server (aka Cassini) currently built-into VS today with the full power of IIS. Specifically:
- It’s lightweight and easy to install (less than 5Mb download and a quick install)
- It does not require an administrator account to run/debug applications from Visual Studio
- It enables a full web-server feature set – including SSL, URL Rewrite, and other IIS 7.x modules
- It supports and enables the same extensibility model and web.config file settings that IIS 7.x support
- It can be installed side-by-side with the full IIS web server as well as the ASP.NET Development Server (they do not conflict at all)
- It works on Windows XP and higher operating systems – giving you a full IIS 7.x developer feature-set on all Windows OS platforms
IIS Express (like the ASP.NET Development Server) can be quickly launched to run a site from a directory on disk. It does not require any registration/configuration steps. This makes it really easy to launch and run for development scenarios.
Visual Studio 2010 SP1 adds support for IIS Express – and you can start to take advantage of this starting with last month’s VS 2010 SP1 Beta release.
Downloading and Installing IIS Express
IIS Express isn’t included as part of the VS 2010 SP1 Beta. Instead it is a separate ~4MB download which you can download and install using this link (it uses WebPI to install it).
Once IIS Express is installed, VS 2010 SP1 will enable some additional IIS Express commands and dialog options that allow you to easily use it.
Enabling IIS Express for Existing Projects
Visual Studio today defaults to using the built-in ASP.NET Development Server (aka Cassini) when running ASP.NET Projects:
Converting your existing projects to use IIS Express is really easy. You can do this by opening up the project properties dialog of an existing project, and then by clicking the “web” tab within it and selecting the “Use IIS Express” checkbox.
Or even simpler, just right-click on your existing project, and select the “Use IIS Express…” menu command:
And now when you run or debug your project you’ll see that IIS Express now starts up and runs automatically as your web-server:
You can optionally right-click on the IIS Express icon within your system tray to see/browse all of sites and applications running on it:
Note that if you ever want to revert back to using the ASP.NET Development Server you can do this by right-clicking the project again and then select the “Use Visual Studio Development Server” option (or go into the project properties, click the web tab, and uncheck IIS Express). This will revert back to the ASP.NET Development Server the next time you run the project.
IIS Express Properties
Visual Studio 2010 SP1 exposes several new IIS Express configuration options that you couldn’t previously set with the ASP.NET Development Server. Some of these are exposed via the property grid of your project (select the project node in the solution explorer and then change them via the property window):
For example, enabling something like SSL support (which is not possible with the ASP.NET Development Server) can now be done simply by changing the “SSL Enabled” property to “True”:
Once this is done IIS Express will expose both an HTTP and HTTPS endpoint for the project that we can use:
SSL Self Signed Certs
IIS Express ships with a self-signed SSL cert that it installs as part of setup – which removes the need for you to install your own certificate to use SSL during development. Once you change the above drop-down to enable SSL, you’ll be able to browse to your site with the appropriate https:// URL prefix and it will connect via SSL.
One caveat with self-signed certificates, though, is that browsers (like IE) will go out of their way to warn you that they aren’t to be trusted:
You can mark the certificate as trusted to avoid seeing dialogs like this – or just keep the certificate un-trusted and press the “continue” button when the browser warns you not to trust your local web server.
Additional IIS Settings
IIS Express uses its own per-user ApplicationHost.config file to configure default server behavior. Because it is per-user, it can be configured by developers who do not have admin credentials – unlike the full IIS. You can customize all IIS features and settings via it if you want ultimate server customization (for example: to use your own certificates for SSL instead of self-signed ones).
We recommend storing all app specific settings for IIS and ASP.NET within the web.config file which is part of your project – since that makes deploying apps easier (since the settings can be copied with the application content). IIS (since IIS 7) no longer uses the metabase, and instead uses the same web.config configuration files that ASP.NET has always supported – which makes xcopy/ftp based deployment much easier.
Making IIS Express your Default Web Server
Above we looked at how we can convert existing sites that use the ASP.NET Developer Web Server to instead use IIS Express.
You can configure Visual Studio to use IIS Express as the default web server for all new projects by clicking the Tools->Options menu command and opening up the Projects and Solutions->Web Projects node with the Options dialog:
Clicking the “Use IIS Express for new file-based web site and projects” checkbox will cause Visual Studio to use it for all new web site and projects.
We think IIS Express makes it even easier to build, run and test web applications. It works with all versions of ASP.NET and supports all ASP.NET application types (including obviously both ASP.NET Web Forms and ASP.NET MVC applications). Because IIS Express is based on the IIS 7.5 codebase, you have a full web-server feature-set that you can use. This means you can build and run your applications just like they’ll work on a real production web-server. In addition to supporting ASP.NET, IIS Express also supports Classic ASP and other file-types and extensions supported by IIS – which also makes it ideal for sites that combine a variety of different technologies.
Best of all – you do not need to change any code to take advantage of it. As you can see above, updating existing Visual Studio web projects to use it is trivial. You can begin to take advantage of IIS Express today using the VS 2010 SP1 Beta.
Hope this helps,