The IIS compression Series
Part 1 Starting with
this article, I'll show how to get the most out of the compression features built into IIS 7 and IIS 6. This first article focusses specifically
on IIS 7.
Part 2 In this article, Matt Perdeck
shows how to make the most out of IIS 6 compression.
Part
3 In this article, Matt Perdeck shows how to enable compression in your development environment, so you can keep track of how large your
pages will be as they travel over the Internet to the browser.
Introduction
When you make changes to your site in Visual Studio, you want to know the effect those changes have on file sizes, both before and after
compression. Unfortunately, the Cassini development server included with Visual Studio doesn't support compression. So you'll need to use IIS
instead of Cassini during development.
Making this happen involves a simple five-step process:
- Install IIS 7;
- Enable compression;
- Create a development site in IIS;
- Run Visual Studio in administrator mode;
- Modify your project so it uses the development site.
Lets do these steps one by one.
Install IIS 7
- Follow these steps to install IIS on Vista or Windows 7:
- Click on Start | Control Panel | Programs | Turn windows features on or off.
- Check Internet Information Services.
- Expand the Internet Information Services node, expand Web Management Tools, and make sure IIS Management Console
is checked. This will allow you to run the IIS Manager.
- Expand IIS 6 Management Compatibility and make sure IIS Metabase and IIS 6 configuration compatibility is checked. You
need this to be able to use IIS from Visual Studio.
- Expand the World Wide Web Services node and then the Application Development Features node. Make sure that ASP.NET
is checked so that the server can run ASP.NET applications.
- Still under World Wide Web Services, expand Performance Features, and make sure Http Compression Dynamic is
selected. This enables the server to compress
.aspx files.
- Also under World Wide Web Services, expand Security and make sure Windows Authentication is selected. You need
this to be able to use IIS from Visual Studio.
- Click on OK. Windows will take a while to implement the changes.

Enable compression
You've seen how to do this in part 1 of this series. Here is a recap:
- Open IIS manager. Click on Start | Control Panel. Type admin in the search box. Click on Administrative
Tools and double-click on Internet Information Services (IIS) Manager.
- Click on your machine. Then double-click on the Compression icon on the right-hand side. The compression window opens.
- Enable compression for dynamic content and/or static content; the same settings you apply in your production environment. Click on
Apply to enable compression.
Create a development site in IIS
Create a site in IIS to use from Visual Studio:
- While still in IIS Manager, expand your machine. Right-click on Sites and choose Add Web Site. The Add Web Site
dialog opens.
- Make up a site name. As the physical path, enter the root folder of your source files, that is, the one with
default.aspx
and web.config. Enter a port that isn't already in use, for example 1080 and click on OK.

- Enable Windows Authentication. Double-click on your new site, double-click on Authentication, right-click on Windows
Authentication, and choose Enable.
Run Visual Studio in administrator mode
To use Visual Studio with IIS, you need to run Visual Studio in administrator mode. If you are not normally logged in as administrator, right-
click on Visual Studio and choose Run as administrator.
To make things easier, you could also create a shortcut to Visual Studio and
on the Compatibility tab of the Shortcut Properties, select Run this program as an administrator.
However, this may
stop you from opening a solution file by double clicking it. The problem is caused by the Visual Studio Version Selector, which is in charge of
opening the correct version of Visual Studio based on the solution file (VS 2010, VS 2008, etc.) The solution is here.
Modify your project so it uses the development site
Finally, swap Cassini for IIS in your project. How to do this depends on whether you use a website or a web application.
If you use a
website:
- Run Visual Studio as administrator. Right-click on the website and choose Start Options. The Property Pages window
opens, with the Start Options tab selected.
- In the Server section, select Use custom server. In the Base Url field, enter the localhost address with the
port you entered when you created the development site in IIS manager:

If you use a web application:
- In Visual Studio, right-click on the web application and choose Properties. The Properties window opens.
- Click on the Web tab.
- Scroll down to the Servers section and select Use Local IIS Web server. In the Project Url field, enter the
localhost address with the port you entered when you created the development site in IIS manager.
- Save the properties.
To see more options such as using Visual Studio with a remote IIS 7 Server, visit here for Visual Studio 2008 and Visual Studio 2010 or here for Visual Studio 2005.
Be aware
that if you use output caching, when you refresh a page, the server will get the page from cache and your breakpoints won't be hit.
Measure the size of your pages
In part 1, you already saw how to measure the actual size of your compressed pages as they will travel over the Internet to the browser, using
the Web Developer add on for Firefox or Google Chrome. This gives you lots of information about a web page, including the compressed and
uncompressed sizes of the files making up page page. In case you haven't installed Web Developer yet, here are the instructions again for
Firefox:
- Using Firefox, visit http://chrispederick.com/work/web-
developer to download and install the Web Developer add on.
- After you have installed Web Developer, load the page you are interested in using Firefox.
- Right click anywhere in the page. A popup menu will appear. Click Web Developer | Information | View Document
Size. A new window appears showing the groups of files making up the page.
- Expand the Documents group to see the main html file. You will see its size. If it was compressed while travelling over the
Internet, you will also see its compressed size.
- For more information, expand the Scripts and Style Sheets groups as well.
Summary
In this article we saw how to use IIS 7 with Visual Studio in your development environment. This allows you to use compression while your new
web pages are under development, so you can keep track of their actual size as they will travel over the Internet to the browser.
In the
next article, we'll address some miscellaneous topics related to compression, such as how to make your pages more compressible.
If you enjoy
this series and want to know the full story on how to improve ASP.NET site performance, from database server to web server to browser, consider my
book ASP.NET Site Performance Secrets. Or visit my web site ASP.NET Performance.
The IIS compression Series
Part 1 Starting with
this article, I'll show how to get the most out of the compression features built into IIS 7 and IIS 6. This first article focusses specifically
on IIS 7.
Part 2 In this article, Matt Perdeck
shows how to make the most out of IIS 6 compression.
Part
3 In this article, Matt Perdeck shows how to enable compression in your development environment, so you can keep track of how large your
pages will be as they travel over the Internet to the browser.
About Matt Perdeck
 |
Matt has over 6 years .NET and SQL Server development experience. Before getting into .Net, he worked on a number of systems, ranging from the largest ATM network in The Netherlands to embedded software in advanced Wide Area Networks. He has lived and worked in Australia, The Netherlands, Slovakia a...
This author has published 4 articles on DotNetSlackers. View other articles or the complete profile here.
|
Other articles in this category
IIS FTP User Isolation - Week 46
This week we walk through the five isolation modes to gain a full understanding of the IIS FTP metho...
FTP Firewall settings, Active vs. Passive, and FTPS Explicit vs. Implicit Week 47
Understanding Active and Passive mode for FTP is useful for troubleshooting and ensuring that the fi...
Q&A. DNS Load Balancing, Google and Geo-location, CDNs-Week 50
This week answers two Q&A questions from viewers. DNS Load Balancing and then some discussion and a ...
Q&A. What’s new in IIS8, Perf, Indexing Service–Week 49
This week I'm taking Q&A from viewers, starting with what's new in IIS8, a question on enable32BitAp...
IIS FTP Troubleshooting - Week 48
This lesson covers ways to troubleshoot IIS FTP. When it works, it works well, but if you run into i...
You might also be interested in the following related blog posts
TIP: How To Generate a Fully Qualified URL in ASP.NET (E.g., http://www.yourserver.com/folder/file.aspx)
read more
Don’t use Response.End() with OutputCache
read more
"Software is everything. (It also sucks.)" - What does this have to do with DotNetNuke?
read more
ASP.NET tab in IIS, more dangerous than it first appears!
read more
Digging into ASP.NET MVC - Part 1
read more
Software Design Best Practices Debate
read more
Application vs. AppDomain
read more
Nothing is Trivial!
read more
Staples Launches Nationwide Computer and Office Technology Recycling Program
read more
DotNetNuke 4.5 and ASP.NET AJAX
read more
|
|
Please login to rate or to leave a comment.