Where are ASP.NET 2.0 Website Project Properties Stored?
Earlier today someone asked me where are the project properties of ASP.NET 2.0 web site stored? This seemingly simple question proved lot more difficult to answer since there is no .CSPROJ file for the web site (I was working with C# and hence .CSPROJ).
I started by creating a new ASP.NET 2.0 Web site project (you can create this on HTTP or file system, the behavior is the same). After that I went to the project properties dialog and modified a few properties like in Start action group, I modified Specific page to some value dummy value and in the Server group I modifed to point to some custom server. Do note that the custom server option can't be set if you created the web site on HTTP.
After this I saved the solution and closed Visual Studio to ensure that all data will be written to disk. However I didn't find any .CSPROJ file in the folder where I had created the project. I decided to search the other paths I knew are used by Visual Studio to store data and first looked at "C:\Documents and Settings\atulg\My Documents\Visual Studio 2005\Projects".
I could see only the .SLN and .SUO files here and no sign of any .CSPROJ file. The SLN file had solution specific entries and the SUO had Visual Studio settings. I then searched the other location where typically files for ASP.NET Site are maintained and that is "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files". However this folder contains files related to code and compiled output and again there wasn't any sign of .CSPROJ file.
I searched the registry but no luck. The project settings were definitely being saved somewhere since I could reopen the web site in Visual studio and see the values as set by me. I copied the project to another machine and when I opened the web site there, I didn't see my custom values, but the default values. This just reconfirmed that the project settings were being saved some place on local machine, but where remained a mystery.
Finally I got an idea and decided to use FileSystemWatcher class to monitor file writes on my machine and hence locate where the information was being saved. I started with Path as "C:\" and NotifyFilter as "NotifyFilters.LastWrite". However when I put a watch on C:\, it resulted in a whole lot of events being generated and I couldn't essentially make out anything.
I suspected the information to be getting stored somewhere in the Documents and Settings folder so I narrowed the Path to "C:\Documents and Settings\atulg". This time, the data was more manageable and I saw writes happening to two files inside of "C:\Documents and Settings\atulg\Local Settings\Application Data\Microsoft\WebsiteCache".
One was to FileAttributes.xml inside another subfolder by the name of the solution and one was to Websites.xml. The FileAttributes.xml didn't contain data of interest, however the other one did and I was finally seeing the project properties data in the Websites.xml file as below
<Website RootUrl="E:\Work\v3.0\ProjTestWebsite\" CacheFolder="ProjTestWebsite" startpage="whatis this.aspx" customserverurl="http://localhost/ThreadlTest/Default.aspx" addnewitemlang="Visual C#" vwdport="4103" enablevswebserver="false" startaction="1" _LastAccess="4/24/2007 2:18:35 PM"/>
The startpage and customserverurl attributes contained values that I had assigned via the project properties screen.
For those of you who work with Vista, the path for Websites.xml will be as "C:\Users\atulg\AppData\Local\Microsoft\WebsiteCache".
Do note however, that the entries to this file are written when either Visual Studio is closed or you open another project/solution in it. Just by hitting Save or Save All won't write the project properties in the file.