One solution for HTTP Error 500.21 – Internal Server Error

When I set IIS web server, I met multiple times about HTTP Error 500.21 – Internal Server Error.

I can not remember what the error screen exactly was, next time I must copy the screen.

I always forget how I got big help using a fast solution:

JUST RUN the command aspnet_regiis.exe –i

Very simple but you have to know it is not always working, but it is the one of you can choose to try.

Links about First Load Web App on IIS

If you used IIS server or Windows Hosting, you might know an annoying problem that if your website not be visited for while, the next visiting needs longer loading time, you have to wait up to over 60 seconds if your hosting is not good. This is because IIS has a feature for low traffic websites it recycles unused worker processes.

Continue reading “Links about First Load Web App on IIS”

Deploy an ASP.NET Project on IIS 6

One of our ASP.NET project was built based on .NET 4 and focused on IIS 7.x web server, but doesn’t matter, IIS 6 support .NET 4.0 well, so we should be able to deploy the project on IIS 6 server too.

Our system is Windows Server 2003 and IIS 6.

1: Load IIS Manager (Internet Information Services Manager)


2: Right mouse click “WebSites” and select “Web Site …” to create a new website:


3: Now we see the Web Site Creation Wizard, just follow it and click Next button:


4: Give a website description (Please know this description is actually the “website name” which will be shown under the Websites node in IIS Manager, just like the “Default Web Site”), click Next button:


5: Set an IP Address for your website, or just keep default settings if you are installing your website for a temporary testing, just like us.

Note: If you set (All Unassigned) IP addresses, then it will set your current computer’s IP address as the website’s IP address.

About TCP port, the default HTTP port is 80, you can set another port number such as 81 for your new website, but in real environment, you should always use 80 for your website. And, please know all your web projects normally should use 80 port, so you should create different Virtual Directories for your different websites or web applications.

About “Host header”, this is used for in case of you want to install multiple websites under a single URL or domain name such as

For our case, we keep all as default settings, and click Next button directly:


6: Now we enter a physical path on computer to be our new website home directory, we can directly click Browse button to choose one or create a new folder:


7: Now, choose Web site access permissions, normally, we should check on Read and Run scripts, if your web application includes some executable dll or CGI, you should check on Execute option also:


8: Now you can click Finish button to finish your steps:


9: Now you can see your new website showing under the Web Sites node, but its status is Stopped:


10:  Now you can right click the new website and try to Start it:


11: You will see the following error message:

IIS was unable to start the site. Another site may already be using the port you configured for this site. Please select a unused port for this site.


Actually this error for sure occurred because we set the 80 port to this new website, but actually the port 80 has already set to the “Default Web Site” which we have mentioned above.

So we either can set a new port number like 8080 to our new website, or change the existing Default Web Site’ port number to another number so that we can use 80 port.

12: Change existing default web site’s port number:

We change existing “Default Web Site” port number from 80 to 8080: Right click “Default Web Site” and choose Properties:


13: Change the port number from 80 to another number:


14: Now you should be able to start your new website, try to repeat step 10, you will see your new website now started:


15: We should also make sure which ASP.NET version is set currently, right click new website and select properties, and open ASP.NET tab, change the ASP.NET version to newest one which you have installed on current computer:


When you click OK, you will see the following message that tell you the web service should be restart, just click Yes button to restart the W3SVC service:


16: It is the time to copy your website content to the new website folder, copy your web application files and folders to the new website folder, which we created above in step 6, the folder name is CCWeb:


Actually before you copy your web application files, you should set right database connection string, and also corresponding Web URL if your web application used Web URL, such as WCF Service URL and Silverlight Service consume client application.

17: After you finished all above steps, now you just open your web browser, and input the address:  
     http://localhost/, you should see your website now.



Good luck, friends!

Install IIS 6 on Windows Server 2003

IIS 7.X web server versions are more and more popular, but there are still lots of real customers using old system, such as Windows Server 2003, they don’t want to upgrade the system now, especially those old servers are working for their existing system. So if you have ASP.NET projects which need an IIS web server, you have to install IIS 6.0 on Windows Server 2003.

Firstly, we should know Something about IIS.

Then let us install IIS 6 on Windows Server 2003.

There are 2 methods (Actually due to Microsoft, there are at least 3 methods) to install IIS 6 on Windows Server 2003:

Method 1: Using Manage Your Server

1: From the Start menu, select “Manage Your Server”


2. In “Manage Your Server” Windows, just under “Managing Your Server Roles”, click “Add or remove a role”.


3. In “Preliminary steps” window, Click Next:


4: Now system is checking your network settings:


4. After a short while, you will see the following screen, Because we are installing an IIS web server, so we should select “Application server (IIS, ASP.NET)”:


5. On the Application Server Options window, Check on the appropriate check boxes, and then click Next (we checked on both of them).


6. You will see the summary window similar like following, click Next:


7. Continue to complete the wizard, and then click Finish.


Method 2: Using Control Panel

1. From the Start menu, click Control Panel, choose “Add or Remove Programs”:


2. Click “Add/Remove Windows Components” on the left side:


3. In the Components list box, check on “Application Server”


4. Here you can click the “Details…” button to see more details of Application Server, we can see the IIS (Internet Information Services) and ASP.NET are just in the subcomponents list, which are what we just need.

Check on IIS, ASP.NET and all options which you want. 


5: And click Next button to continue to IIS 6 installation.

Above are the 2 methods which we often to choose. for more methods, please read Microsoft official Install IIS 6.

Something About IIS

IIS is the Web Server software from Microsoft. Normally IIS is a part of Windows OS system, it means you do not need to purchase an IIS separately.

The  IIS version and Windows system version matches (Due to the record from Wikipedia):

IIS 1.0 was a free add-on for Windows NT 3.51.
IIS 2.0 was included with Windows NT 4.0.
IIS 3.0 was included with Windows NT 4 SP3
IIS 4.0 was released as "Option Pack" for Windows NT 4.0.
IIS 5.0 shipped with Windows 2000
IIS 5.1 was shipped with Windows XP Pro
IIS 6.0 was included with Windows Server 2003 and Windows XP Pro x64 Edition
IIS 7.0 was a complete redesign and rewrite of IIS, and was shipped with Windows Vista and Windows Server 2008.
IIS 7.5 included in Windows 7 and Windows Server 2008 R2.
IIS 8.0 is only available in Windows Server 2012 and Windows 8.

And, we must know the IIS version is for corresponding Windows OS version, for example: IIS 7 can not installed on Windows server 2003; and, IIS 6 can not installed and run on Widows server 2008 and Windows 7; 

How to use IIS Express

About how to use IIS Express is simple, and easy to search many helpful information. So I did not want to write a blog to record how to use IIS Express. However, there were not only one or two times, I and my team members still need to find out how to use sometimes since we forgot the process even it is so simple.

OK, let me start the simple steps:

(Note: the following steps only tested on Windows 7)

1: Download IIS Express and install it on your computer:

I downloaded IIS 7.5 (here is downloading link). I don’t know whether you could get any error message if you did not install .NET 4.0 framework first, if you really get a related error message, please followed the tip message to install or fix something first;

2: After installation, Go to “Documents” folder:


3: Choose “IISExpress” folder , and then “config” folder, open the file “applicationhost.config” using a text editor such as Notepad or Notepad++::

Update:  If you can not see an IISExpress folder in your Documents folder, please go to “c:\Program Files (x86)\IIS Express\” (64-bit system) or “c:\Program Files\IIS Express”(32-bit system) to run IISExpress.exe once time, and then you can find a “IISExpress” folder was generated under your Documents folder.


4: Locate at the line of “<sites>”, you can add a new site inside <sites> and </sites> tab:

Please check the following screen shot: The content in the blue box is a new website, the 4 boxes in red color are the content which you should change due to your own settings:


name=”MyMVC3”: Giva a name to your new site.

id=”127” : you set a unique id number for your new website;

physicalPath: it is the folder which your web published files and content, for example, you got a generated web zip file, just unzip it to any folder what you want. for my case, I put them to “C:Users\Tony\Desktop\MyMVC3\ folder”, like the following:


bindingInformation: this is for a port number, you can put a valid port number as long as it is not limited for Windows system.

The following is the text content:

<site name="MyMVC3" id="127" serverAutoStart="true">
    <application path="/">
        <virtualDirectory path="/" physicalPath="C:\Users\Tony\Desktop\MyMVC3\" />
         <binding protocol="http" bindingInformation=":3576:localhost" />

5: After above settings, go to DOS Command UI, and run the following 2 lines of commands:

cd C:\Program Files (x86)\IIS Express

iisexpress /site:MyMVC3

MyMVC3 is my site name which I set in config file above;

because My windows 7 is 64-bit system, so I used the folder Program Files (x86), if your Windows 7 is 32-bit system, just use “cd \Program Files\IIS Express”;

Now you can see the following DOS command screen, you now see IIS Express has already register a URL for your website MyMVC3, my case is http://localhost:3576/


6: User your web browser to open the URL http://localhost:3576/, you will see your website now:


Actually, I just gave ONE example to use IIS Express, for more details, please visit Microsoft IIS Official site and check more IIS Express settings.

Hate installations? Use Lightweight IIS and SQL Server

When you build an ASP.NET application, you might fee some boring works which you have to install a SQL Server database , no matter you can install SQL Server Express version, but you still have to install it. and also, if you want to try your application without using Visual Studio, you have to install IIS or set the existing IIS in your Windows system.

Now you will no more hate the above 2 works: Microsoft has provided you 2 new great products:

1: IIS Developer Express (This was called by Microsoft’s Scott Gu before, now the formal name is IIS Express, or include version number such as IIS 7.5 Express):
 A lightweight web server, a lightweight IIS, even it is compatible with IIS 7.5

2: SQL Server Compact Edition:
 A lightweight file-based SQL Server database.

About IIS Express (From Scott Gu’s blog):

    It’s lightweight and easy to install (less than 10Mb download and a super 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, Media Support, and all 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 OS platforms

Actually, IIS Express has been released. You have 2 ways to get it:

1: If you use WebMatrix, IIS Express has been included with WebMatrix, you just need to install WebMatrix only;
2: If you want to install IIS Express only;
All details info, please read Microsoft Official site here about IIS Express

About SQL Server Compact Edition (SQL Server CE – This was Scott Gu’s called before, now the version called SQL Server Compact 3.x)

Below content copied from MS Official site:

SQL Server Compact is a free SQL Server embedded database ideal for building standalone and occasionally connected applications for mobile devices, desktops, and Web clients.

Top Features:

    Free to use and distribute
    Supports desktops and mobile devices
    Small footprint for easy deployment
    Fully embeddable architecture
    No administration required
    Single file, code-free database format
    Support for ClickOnce, XCopy, MSI, CAB, and non-admin embedded installation options
    Supports all Microsoft Windows embedded, mobile, desktop, and server operating systems
    Supports a rich subset of Transact-SQL syntax and SQL Server data types
    Microsoft Visual Studio 2008 integration
    Supports ADO.NET, LINQ to SQL, LINQ to Entities, and the ADO.NET Entity Framework
    Supports multiple concurrent local connections

All detail information please read MS Official site here about SQL Server Compact

BTW: DO not forget to visit Scott Gu’s blog, it is always helpful very much !