This project is read-only.


Introduction and background

information to be added.

How it works

information to be added.

Installation / Configuration instructions

  1. Create a new basic ASP.NET Web application project to your solution that will function as “TestWeb”
  2. Add a project reference to your main SharePoint project
  3. Add a global.asax to (the root) of your testweb. Open the codebehind and add some statements to the Application_Start eventhandler.
    Our VirtualSharePointProvider will be registered as VirtualPathProvider. You need to pass the name of the assembly, assuming it matches the name of your SharePoint project (if it doesn’t, we didn’t test that scenario Smile)
            protected void Application_Start(object sender, EventArgs e)
                string assemblyName = "GoodStuff.SharePoint2010";
                System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider(new GoodStuff.SharePoint2010.Providers.VirtualSharePointProvider(assemblyName));
  4. If the TestWeb has the same parent folder (on your file system) as your main SharePoint project, you don’t have to add an appsetting to the web.config of your new TestWeb. Otherwise you can configure its path by added the appsetting as below
        <add key="GoodStuff.SharePoint2010.Providers.VirtualSharePointProvider.SolutionDir" value="D:\GoodStuff\GoodStuff.SharePoint2010\GoodStuff.SharePoint2010"/>
  5. Next step is adding a masterpage for your testpages. We advise to add the following components
    • <asp:ContentPlaceHolder ID="head" runat="server"/> within the <HEAD> section in case you need additional stylesheets or script includes
    • A style declaration in the HEAD section which hides the WebPart title row (chrome) that ASP.NET renders by default
          <style type="text/css">
              /*Hide WebPart titles*/
              BODY > TABLE > TBODY > TR > TD > TABLE > TBODY > TR > TD > TABLE > TBODY:first-child > TR:first-child
                  display: none;
    • A scriptmanager within the BODY section of your HTML
      <asp:ScriptManager EnablePageMethods="false" ScriptMode="Release" EnableScriptGlobalization="true" EnableScriptLocalization="false" runat="server" />
    • A WebPartManager within the BODY section of your HTML
      <asp:WebPartManager runat="server" ID="wpm" Personalization-Enabled="false" Personalization-InitialScope="Shared" />
    • <asp:ContentPlaceHolder ID="PlaceHolderMain" runat="server"/> for the main content of your testpages.
  6. Now you are ready for your first testpage. A couple of last steps left …
    • Register the VisualWebPart, or a regular WebPart. Note that by default this RedirectWebPart class has the .RedirectWebPart namespace 
    • Add the asp:Content for the specifying the content of the PlaceHolderMain
    • Add a WebPartZone to the page, with a ZoneTemplate 
    • Add your WebPart to the ZoneTemplate 
      <%@ Register Assembly="GoodStuff.SharePoint2010, Version=, Culture=neutral, PublicKeyToken=3241d6f3eb95dd1c" Namespace="GoodStuff.SharePoint2010.WebParts.RedirectWebPart" TagPrefix="cc1" %> <asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server"> <asp:WebPartZone runat="server" ID="zone1" PartChromeStyle-BorderStyle="None"> <ZoneTemplate> <cc1:RedirectWebPart runat="server" id="testLogin" ShowProcessHeaders="true" /> </ZoneTemplate> </asp:WebPartZone> </asp:Content>
  7. Add the following Post-build events to the properties of your TestWeb project(file). This is the ensure that while running and/or debugging your TestWeb you will use the latest builds of your assemblies (if a copy is available in the GAC it will override the local copy in the \BIN of your TestWeb which will cause an unattached debugger). If your main SharePoint project has additional projectreferences (like Class Library projects) you need to add additional lines to uninstall that assemblies.
    "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil" /u GoodStuff.SharePoint2010
    • If you besides the TestWeb also develop, test and deploy to (local) SharePoint site, every time your solution your site won’t work any more (due to the fact that assemblies are removed from the GAC).
      In that case you can exclude building TestWeb when the solution build (Menu –> Build –> Configurationmanager). Of course you than need to manually build your TestWeb (rightmousebutton on your TestWeb project –> Build will do that trick).
  8. Now you are ready to fire up your TestWeb. Select your testpage and run it (pressing CTRL+F5 for example, or rightmouseclick it and select “View in browser”)



Known improvements

  • Find a way to avoid the need to remove the assemblies from the GAC to ensure latest builds will be used in TestWeb while running and/or debugging. If you or use the SharePoint project (testing within SharePoint context / website) only or use the TestWeb only this isn’t an issue.

Last edited Jul 4, 2012 at 11:27 PM by Markuz, version 4


No comments yet.