I thought I had everything working great till I removed an override template file.
I have a website that is made of up modules (class library dlls). I use IIS Virtual Directories so that everything is compilable and debugable from one solution file. The root project is basically empty. I'm trying to build the whole core site in the various modules so that I can then allow for easy overrides by dropping them into the core website project. I have a MasterPage and a ContentPage in the main module. At design time, VS 2008 works great and it finds the master page from the virtual directory based module project and I can edit the content page. But it won't run unless I create a copy of that master page in the root directory (basically the same path minus the initial module directory). At runtime, it's resolving MasterPageFile="~/_Templates/Pages/Main.Master" which goes to the root directory. I can't change the design time version to be MasterPageFile="~/AppCore/_Templates/Pages/Main.Master" because at design time, VS 2008 is already resolving ~ to /AppCore which then doubles it up and it won't find it. In any event, I don't even want it to resolve this setting because my BasePage class is going to override the MasterPageFile setting anyways. But it won't get that far since it complains that it can't find the initially set master page file.
So basically
1) There's different behaviour in VS2008 for the ~ for multi-project module based webprojects that use IIS virtual directories between designtime and runtime. Is this a bug?
2) While I see that one can dynamically change the MasterPageFile, it seems they still need to ensure that the MasterPageFile that the content page @page directive references is still available even though you don't want to use it. Is there anyway to override this? In my case I need to ensure it's available in the 'wrong' directory because of how VS treats the ~. It seems like the aspnet engine is checking for the existence of the MasterPageFile setting in the @page directive before the class that page inherints from PreInit fires. I think this is also a bug. Shouldn't it wait to check for the existence of that MasterPageFile until AFTER PreInit so that users can change the MasterPageFile setting and not have to worry about keeping the other file around.
Right now my only option is to remove the MasterPageFile setting from the content page and I loose ALL visual editting. Such a shame because the class checks for the existence of the master file to early.