Thursday, February 08, 2007

Fixing Intellisense in Web.config

A few days after I began reading Pro ASP.NET 2.0 in C# 2005, I ran into a problem that disabled Intellisense when working in Web.config. It seems I'm not the only one to have experienced this problem: Scott Guthrie and Tim Gaunt, whose blogs I frequent, encountered the same issue.

The problem was that the following line of code in Web.config:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

Should be:
<configuration>

The xmlns property appears to be inserted every time the Web Site Administration Tool is used. Anyway, I did some digging around and found an answer posted by Massimo Prota in the comments section of Scott Guthrie's blog post about the same problem. Here's what Massimo suggests:

1. Open the folder %windir% \ Microsoft.NET \ Framework \ v2.0.50727 \ ASP.NETWebAdminFiles \ App_Code.

2. In the above folder, open WebAdminPage.cs and in the SaveConfig method (line 93), change the value of config.NamespaceDeclared to false.

UPDATE - Massimo's suggestion didn't fix the problem for me: the xmlns property is still added to my Web.config every time I change something in the IIS Website Name > Properties > ASP.NET > Edit Configuration screen. However, if anybody finds that it does work for them under Windows Server 2003, please let me know...

No comments: