I was working on improving an application the other day and I noticed something in the web.config file. I do not know if it is by design just in VS 2008 or if it was included in VS 2005 but you can include all your Imports in the web.config file. I have not looked into how much this will cost the application to include everything all the time even though it is not being used but it makes for cleaner code. Here is what needs to be done:
<configuration>
<system.web>
<pages>
<namespaces>
<clear/>
<add namespace=”System”/>
<add namespace=”System.Collection”/>
<!—user added namespaces below à
<add namespace=”System.Data”/>
<add namsspace=”System.Data.SqlClient”/>
</namespaces>
</pages>
………
</system.web>
</configuration>
As you can see by the above example, I separate the auto generated namespaces from the ones that I add. That is not required but I do it for my own benefit. Also there may be a place where one can indicate which namespaces to include by default. I have not found that yet. If I do I will let you know. As always, if there are any questions or suggestions, they are welcome. Thank you.