Hand editing web.config or not

I've come across a number of issues in the past where the cause of the issue is that someone hand edited the web.config and resulted to a not well formed XML (missing tags, unclosed quotes et al).

The recommended way of doing it is [more]to minimize these issues is to use the ASP.NET Configuration Settings Dialog which is available to IIS (not sure if there is a stand alone executable for this). Here are simple steps to do it.

1. Open IIS

2. Right Click on target site/virtual directory and select Properties

 

3. The Properties dialog should show up. Select ASP.NET tab.

 

4. At the ASP.NET tab, you should see and click Edit Configuration. (if you're opening Properties of a website, you should also see an "Edit Global Configuration" button which corresponds to the machine wide web.config). Doing so should display the Configuration Settings Dialog

 

5. Make your modifications without fear of unclosed quotes whatsoever. You could likely still mess up some settings but I can assure you that it would be easier to do when you're manually hand editing the file.

 

Also note that when adding a web.config in Visual Studio (using Add New Item) you will get a comment somewhere at the top stating: 

<!–

    Note: As an alternative to hand editing this file you can use the

    web admin tool to configure settings for your application. Use

    the Website->Asp.Net Configuration option in Visual Studio.

    A full list of settings and comments can be found in

    machine.config.comments usually located in

    WindowsMicrosoft.NetFrameworkv2.xConfig

–>


The "Website->Asp.Net Configuration option in Visual Studio" mentioned are items in the toolbar and appears if you have the website project (or its files) open/selected (see image below)

And you should see something similar to image below

 

You can also check the "How do I use this tool" link at the top right of the page.

This is also a recommended way of doing it for web site projects (not available in Web Application Projects).

Editing web.config is likely inevitable for development but as much as possible I would recommend not hand-edit them unless you (or others in the team) really have to (especially for those with not much experience with XML/HTML – it is trivial but could minimize some headaches)

UPDATE: I've also cross posted this on weblogs.asp.net and getting some useful comments so you might also want to check it out using the following link : post on weblogs.asp.net 


Posted

in

by

Tags: