Your official information source from the .NET Web Development and Tools group at Microsoft.
This is the Part 3 of a 3 part series on using sub-projects with the Web Application Projects add-in for Visual Studio 2005.
Part 1 of the series can be found here.Part 2 of the series can be found here.
This post covers the final concept I wanted to share when using sub-projects with the Web Application Projects add-in, that is using a sub-project structure without using IIS, but instead with the built-in Visual Studio Development Server.
Setting up the Root Project
To create the root project follow the instructions as they are described in Part 1 of this series. The primary difference when using the Visual Studio Development Server is to set the project properties of the root project to not use IIS and to use a specific port with the Visual Studio Development Server as shown in the diagram below:
Setting up the Sub-Project
Once again, creating and setting up the sub-project is done the same as described in Part 1 of this series, the primary difference being the settings in the "Web" tab of the project properties for the sub-project. For the sub-project, on the "Web" tab of its project properties, leave the setting to "Use IIS Web Server" (somewhat ironic as in this case it will actually use the Visual Studio Development Server). Also, set the Project URL value to: http://localhost:[port]/[subprojectfolder], where [port] is the Specific Port you selected for the Visual Studio Development server on the Root project, in this case "8080", and [subprojectfolder] is the name of the sub-folder where the sub-project is located inside the root project, in this case "SubProject1".
NOTE: This post only describes the differences in setting up a sub-project's settings when using the Visual Studio Development Server. You will still needs to perform all the the other steps described in Part 1 of this series to configure the sub-project property (e.g. - deleting the web.config in sub-project, setting correct output path in sub-project, setting a project reference to root project in sub-project).
Running pages in the Sub-Project
The final aspect that is different about this configuration from using IIS is how pages in the sub-project are run. The difference is that the Visual Studio Development Server from the root project must be running in order to serve up pages from the sub-project. Thus the first thing one should do is select the page in the root project and run it to make sure the Visual Studio development server is loaded. Once a page in the root project is run, you should be able to run pages from the sub-project with success.
This post finalizes my series on using Web Application projects to partition a single ASP.NET application into several Visual Studio projects. If you cannot use IIS in your development environment, the technique described here will still enable you to take advantage of using a sub-project structure at development time.
As always, looking forward to hearing feedback from users trying this out!
Some members in my team develop on a Windows 2003 Terminal Server. We also use Team Foundation Server to support collaboration. It would seem then that the technique you described in this article precludes collaborative development within a terminal server environment, since each developer's IDE would be contending for control of the same Windows port. Is there no way to use port auto-assignment with these sub-projects?
I still have no solution using resources as .resx-files in my master-sub-projects. The point is that I am not able to use recources stored in the App_Global/LocalResources-folders in a subproject. So I need to put the resx-files for the subprojects into the App_GlobalResource-folder of the masterproject. Right? But then I am not able to access a resource-string from codebehind in a subproject because it is inaccessible due to it's due to its protection level!
Or am I doing something completely wrong here?
Any comments are welcome!
Thanks in advance.
Well, finally we see part 3 of 3. My conclusion: this is a hack. It's a smart one, and it works, but it is really a hack around Visual Studio. It was not supposed to do this.
You lose some intellisense (subproject doesn't know about ContentPlaceHolders or Themes from Root project) and it is already said that resources don't work.
I really hope this will all be added in SP2. Along with support for nested MasterPages.
Thanks for the great articles though!
Earlier today, I posted to the WCSF CodePlex Community Site a new code-only guidance package, Web Application
It works in run time
In design time, I don't get:
Is there anyone in microsoft who wants to solve this ?
Mainly because this is simple to solve: we need to put in the project properties what is "~" Ex.: "~/MasterPage/abc.master" is not inside the sub project , but in the root project
My company is working in a huge ASP.NET project since .NET 1.1 (since 2004), with ASP sub projects, and I can tell you that this is a nightmare. And also a fine way to burn hours and money...
We already report this accident, several tmes to microsoft, I also saw many people complain about it, but until now, not even a small beep about this...