How To: Creating a VS web application below a SharePoint IIS web application


In certain scenarioes it would be very convenient to create a full Visual Studio web application below a SharePoint web application. This can be when you have a lot of asp.net files which do not have many connections or use of SharePoint functionality, still the must be hosted on the SharePoint server, either due to the hosting scenario or the need for some functionality or connection.

There are some articles on MSDN suggesting how one can create a VS web site project below a SharePoint site. This works more or less like a simple subfolder; it needs you to include both the .aspx files and .cs files. If you don't, you will need to compile your assembly, place it manually in the top \bin folder and manually remove your .cs files. OK - it works, but is not convenient at all. (PS. Do you see the performance difference if you do/don't add your assembly to the safecontrols list in the web.config file? ) Another pain point with this approach, is how can you integrate this with TFS? There are actually a couple of options, but neither are elegant:

  1. Create a WorkSpace working folder for this project and point it to your web servers subfolder. Let the developeres use this and include seperate steps in your teambuilds for test/prod deployments.
  2. Create a VS Web application outside the IIS structure. Create postbuild rules to copy what you need over to the server. Developers will need to attach to w3p process to debug their applications. TFS can however be used in a common way.

Not tempted? Me neither... Luckily, it is possible to create a more or less full VS web application instead. In SharePoint 2003 there is published a couple of articles on the subject, "Creating a Web Application in a SharePoint Web Site" and "Modifying Configuration Settings for an Application to Coexist with Windows SharePoint Services". They work fine with SharePoint 2003 and without giving you access to SharePoint, so if you try to follow them with SharePoint 2007 you actually get thrown of in the wrong direction. But if you follow these steps, you should get you going:

  1. Create a VS web application, as a subfolder in you web site.
  2. Add references to SharePoint assemblies as needed.
  3. Remove your VS web applications local web.config file.
  4. Link to your SharePoint web applications root web.config file in your VS project.
  5. Enable debuging in the web.config file.
  6. In project properties, web, set your project to use IIS instead of your the VS web server.
  7. In project properties, set the output path of your build to be the root folder's bin catalog.
  8. Add information about your assembly in the safecontrols section in the web.config file.

 

You should now be able to run and debug your project simply by pressing F5. So, this got us one step further than the web site project. The last parts with integrating this project with TFS still have some issues. How can you integrate as painless as possible, making it easy for a new developer to download the project and have it running in a couple of minutes? You will still need to have some manual steps and for the developer to set.

The approach described here, might have some other caveats in scenarios other than one described, so take extra precautions implementing it. A more standard approach would be to deploy your application to the _layouts folder, see "Deploying ASP.NET Web Applications in the Windows SharePoint Services 3.0 _layouts Folder" and "How to: Create a Web Application in a SharePoint Web Site" for more information.

Comments (5)
  1. Kris says:

    Thanks for the article. I have always struggled with this. I drove my team to use Web Application project types but when it came to SharePoint it did not work for us. Is there a document that highlights (from a Development perspective) where the assembly files can go to (bin, GAC, etc) and their implications on the app. It would be very helpful to a lot of people.

    Thanks.

  2. Top News Stories Migrating File Shares to SharePoint (Microsoft Certified Professional Magazine) Chris

  3. Top News Stories Steve Ballmer Talks Up the Cloud (vnunet) Microsoft chief executive Steve Ballmer has

  4. Top News Stories Microsoft Will Bow In-Memory Analysis, Appliance-Ready Database in 2010 (intelligent

Comments are closed.

Skip to main content