I've recently reorganised a web app so that instead of all the files sitting in the application root, everything is split into business area sub-folders and beneath that divided into folders by type. So instead of having:
- ~/MasterPage.master
- ~/Page.aspx
- ~/UserControl.ascx
The structure is now like this:
- ~/App/Common/MasterPages/MasterPage.master
- ~/App/Common/Pages/Page.aspx
- ~/App/Common/UserControls/UserControl.ascx
This all works quite well on my machine, everything compiles and runs in Debug or Release mode, however when I deploy to the testing server things go a bit pear shaped. To deploy I create an MSI using _deploy
and _msi
projects in visual studio, then run the MSI on the test server.
User controls that are referenced directly from an .aspx
seem to be OK, but if a User Control has a child user control then errors ensue:
Directory 'C:\Inetpub\wwwroot\WebApp\App\Common\MasterPages' does not exist. Failed to start monitoring file changes.
Directory 'C:\Inetpub\wwwroot\WebApp\App\Common\UserControls' does not exist. Failed to start monitoring file changes.
The directories do not exist on the testing server because there's no files to go in them, all their contents are compiled into DLLs during t开发者_如何转开发he build, so the MSI doesn't have any files to copy into them. If I create the directories by hand then everything starts working even though they're empty, so one obvious fix is to include a blank.html
or similar in each folder so that they get created by the installer; another would be to put the user controls in the same directory with the pages - but that all seems like papering over the real issue: why does the deployed web app needs these directories to exist in the first place?
So there are a few questions I'd like answers to:
- Is this a fundamentally wrong headed approach, can I expect to see further similar issues in the future because of this directory structure in the project? (And if so, what is a better way to organise the app?)
- Is there a way to configure the build so that ASP.net does not need to 'start monitoring file changes'? (Is it something to do with the 'make compiled website updatable option?)
- Is there some good documentation of how all this works somewhere that explains what this issue is?
I have had the same exact error although any UserControl would cause it, regardless of whether it was used by a Page or another UserControl. I believe it only happened if that control was used more than 5 times in a single request.
One workaround is to add an empty Placeholder file to every directory containing a CustomControl and set the Placeholder file's properties to Build Action: Content
, Copy to Output Directory: Copy always
. That keeps the directories from disappearing when the site is published.
精彩评论