Friday, 17 August 2007

Update/Delete .NET 2.0 web application sub directories

Joseph and I have spent a long time figuring out why the session variable is refreshed after a page load. It was working well in .NET 1.0, but it fails when after we've converted the project to .NET 2.0. At first we have no idea it is a .NET 2.0 issue. Actually we didn't even know it is a session variable issue (all we got was the mysterious object null reference exception). Anyway, after some difficult time we found out updating sub directories restart the web application. Unfortunately we have to keep this operation. After some googling we finally found a solution, and here it is.

If the sub directory is linked to another directory (as conjunction), then updating that sub directory would not trigger application restarts. For example my application is in C:\MyApp and the sub directory is C:\MyApp\SubDir. I should create another directory, for example C:\MyAppSubDirLink. Then download Window Server 2003 Resource Kit (here) and install it.

The resource kit has "linkd" command, which is all we need to get this working. Run the following in command prompt:

linkd C:\MyApp\SubDir C:\MyAppSubDirLink


That's it! Now you can update C:\MyApp\SubDir without restarting the web application, and therefore session variable would be preserved!

No comments:

Post a Comment