Application Development on MOSS 2007 & WSS V3

UPDATED 15-March-2007
UPDATED 16-November-2007 (Option 4 updated with steps)

I have been fortunate enough to have been involved deeply with one of our early Office TAP customer's projects. TAP customers are given access to early builds and betas, along with support from Microsoft, to build a project on. The idea here is that they will be in a position to deploy early on the latest technology and at the same time have a positive impact on Microsoft delivering a quality product to market. TAP customers are key to us taking feedback as we build the product.

In the particular project I am involved with we are building quite an elaborate solution that is built using many of the new features in the 2007 Microsoft Office System. This ranges from the InfoPath embedded in a Win Forms control and on to Microsoft Office SharePoint Server 2007.

Here is a brief list of some of the things we are doing:

  • Building a .Net Win Forms application and embedding InfoPath to do rich offline forms capture in a custom application
  • Custom Visual Studio based Workflows build on Windows Workflow foundation
  • Custom Site Definitions, List Definitions, Timer Jobs deployed as Features via the Solution deployment framework
  • ...

But what I really wanted to concentrate on in this post was talking about what options we considered for building some custom UI that is delivered inside MOSS and the pros and cons of each.

The options we looked at were:

  • Custom built Web Parts
  • A "_layouts" application (see below for what this is)
  • App built using User Controls & Son of SmartPart

The particular component of the application that I want to look at is the UI presentation "engine" i.e. what mechanisms deliver the UI.

Option 1: Custom built Web Parts

With this option you build all your UI using the Web Part framework. Logic etc... can be off in other .Net assemblies or a web service etc... just as you would with any other .Net Application.


  • Built using ASP.Net Web Part framework
  • Deployed via Web Part install package or the new Feature/Solution Deployment mechanism
  • SharePoint application provides hosting framework for "putting" these Web Parts on Web Part pages
  • Communications framework for talking with other Web Parts
  • Designed to be highly re-usable across many sites with little effort


  • No drag and drop UI for laying out your UI i.e. no design time surface
  • A framework that developers must learn to work within

Summary: A good use of web parts would be where you want to build a widget/mini-application that you can put on many web part pages across many sites.

Option 2: _layouts application

An _layouts application is when you develop an ASP.Net Web Application and deploy it to the c:\program files\common files\microsoft shared\web server extensions\12\template\layouts (what a mouthful!) directory. This is a special directory that gets "virtualized" in each sharepoint site i.e. in each sharepoint site you will have an /_layouts path from the root of the web. E.g. http://servername/sites/sitename/_layouts.

This means you can make your application available under each SharePoint site e.g. http://servername/sites/sitename/_layouts/MyApp/SomePage.aspx

In fact this is how all the SharePoint administration pages are delivered in each site.


  • Great way to make your functionality available in every site
  • Easy to develop. It is just like developing a regular ASP.Net web site
  • Context sensitive access to the SharePoint object model. Great for doing work on the site that the user happens to be working in at the time.


  • Deployment not managed via Solution deployment mechanism
  • Cant use the ASP.Net master page of the site context as the _layouts application is a separate ASP.Net application

Summary: It is best to use an _layouts based application when you want to extend every site with some functionality such as additional administration pages.

Option 3: User Controls and the Son of SmartPart

The last option is to build your applications UI in ASP.Net User Controls as you would with any other ASP.Net Web Application and then use the Son of SmartPart to deliver those User Controls via a web part.

The Son of SmartPart is a Web Part that is able to "host" an ASP.Net 2.0 User Control 🙂 For more info on this see:
(if you are wondering who its father is ... that is the SmartPart funnily enough ... and is a Web Part for hosting ASP.Net 1.1 User Controls)


  • Simple development experience.
  • You get a design surface to build you UI
  • Deployment reasonably straight forward
  • Can use Web Part connection framework if desired
  • Might be possible to develop these outside of SharePoint first (depending on if they have dependencies to SharePoint).


  • Deployment not managed via Solution deployment mechanism Out of the Box (you could build a solution to deploy the Son of Smart Part)
  • Slightly different deployment of User Control files and assemblies (but nothing a .bat file can't fix) during development.

Summary: I think this is a great option when you want to build a rich browser based UI that you only want to use in one (or a couple) of sites. I don't think this is a good option if you want to build a mini-application that you want to include on many sites. A better option in that case might be a Web Part.

Option 4: ASPX pages added to SharePoint Site -- ADDED 15-March-2007 UPDATED 16-November 2007

(Thanks to Michal Gwozdek for emailing me an updated set of steps that work for him)

This option actually was suggested in the comments by a reader.  I thought it was so good i tried it out ... and it works great!  So here it is.

This option allows you to add your ASP.Net application pages into your SharePoint Site.  It also provides for compiling all using the code behind your pages into a DLL.

In a nutshell this option allows you to build your ASP.Net application outside of SharePoint, build it, test it & then add it to SharePoint.  Its great!

Here is how to do it:

1. Install the Visual Studio 2005 Web Application Projects extension.  This gives you the 'old style' web projects in Visual Studio ... so you can compile down to a single DLL etc...

2. START - File - New Project - ASP.NET Web Application - Name it "ItDoesWork"

3. Add reference to Microsoft.Sharepoint

Leave only Microsoft.SharePoint, System, and System.Web

4. In the Solution Explorer create folder "~masterurl" and add masterpage "default.master" inside

5. Replace code behind for the masterpage with:

using System;
using Microsoft.SharePoint;

namespace ItDoesWork._masterurl

public partial class _default : System.Web.UI.MasterPage

protected void Page_Load(object sender, EventArgs e)



6. In the designer, rename ContentPlaceHolder's ID to "PlaceHolderMain"

7. Delete Default.aspx, and add new page - SamplePage.aspx

8. Replace source content with the following:

<%@ Page Language="C#" MasterPageFile="~masterurl/default.master" CodeBehind="SamplePage.aspx.cs" Inherits="ItDoesWork.SamplePage" Title="Untitled Page" meta:webpartpageexpansion="full" meta:progid="SharePoint.WebPartPage.Document" %>

<asp:Content ID="Content5" ContentPlaceHolderID="PlaceHolderMain" runat="server">

Testing Page...

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>


9. Replace code behind for the page with:

using System;
using Microsoft.SharePoint;

namespace ItDoesWork

public partial class SamplePage : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

Label1.Text = SPContext.Current.Site.Url;




10. Project properties - Build - Output path:

Point it to \BIN folder of our SharePoint Web application. E.g.


You can also manually copy your projects DLL into the \BIN folder each time.

11. Compile your project.

12. Open the web.config file for the SharePoint Web Applicaiton E.g.


13. Add the following line to the SafeControls section (change to suit your assembly and namespace etc...)

<SafeControl Assembly="ItDoesWork" Namespace="ItDoesWork" TypeName="*" />

14. Change the <trust level="WSS_Minimal" originUrl="" /> line to <trust level="WSS_Medium" originUrl="" />

15. Open your site in SharePoint Designer and drag and drop your SamplePage.aspx page into a folder in your site.

16. Browse to your page E.g.

17. Jackpot! (Hopefully) You should now have your aspx page running in SharePoint.

One of the great things about this option is that you could build your applicaiton outside of SharePoint with any old MasterPage, then deploy to SharePoint and swap out the masterpage string for the correct one.  Thus being able to develop and debug outside of SharePoint and then deploy and test inside SharePoint. 

I can see this option being a favorite for most ASP.Net developers who are used to the integrated/seemless code, build & debug experience.

A note on debugging:  If you want to debug your code once it is running inside SharePoint then all you need to do is attach the Visual Studio debugger to the correct w3wp.exe process (Debug -> Attach to process), set your break points and then hit your page in a browser.


  • Simple development experience. Develop outside SharePoint first if desired.
  • You get a design surface to build you UI
  • Deployment reasonably straight forward


  • Deployment not managed via Solution deployment mechanism Out of the Box. ( but this might be possible i have not tried it yet)
  • Slightly different deployment of User Control files and assemblies (but nothing a .bat file can't fix) during development.

I really like this option ... coming from an ASP.Net point of view i feel it is a simple option.


Decision matrix

  Single Site Some Sites Many Sites
Per site functionality Smart Part Smart Part or Web Part Web Part
Single instance application Smart Part or add ASPX pages to site N/A N/A
Site extension functionality Web Part Web Part _Layouts application

In our applications case:

In the project that I mentioned at the beginning of the post the following was true:

  • We wanted to surface application UI in one place in SharePoint
  • There was only ever going to be one instance of the application i.e. surfaced via one SharePoint site
  • Lots of different screens in the UI

Can you guess what option we decided on?

Well, it basically boiled down to either building the UI in Web Parts or using the Smart Part method.

In the end it was built using User Controls and the Smart Part because the developers would be more productive building User Controls (they didn't have any prior SharePoint development experience) and we didn't need to re-use any of the application in multiple sites.

So in the end we ended up with a document library to house Web Part pages for each of the UI "Screens". In each of the web part pages we are using the Son of Smart Part to deliver our User Control that delivers that portion of the application.

I am really keen to hear what other options people are using to develop their applications that are delivered inside SharePoint. Feel free to leave comments ...


Updated:  Changed title to include WSS v3 as Patrick rightly points out this is equally as applicable in WSS v3 also.

Comments (108)
  1. Chris Johnson (Microsoft Consulting Services, New Zealand / TechEd NZ &amp;amp; AU speaker) has written an…

  2. Robin says:

    That decision matrix is very handy! Thnx 🙂

  3. Here is an assortment of various 2007 Microsoft Office SharePoint Server Documentation / Reference Materials…

  4. Background:

    Anyone who is familiar with development &amp;amp; deployment of custom solutions on SharePoint…

  5. Chris Johnson posted a great article on the options for conducting UI application development in MOSS…

  6. Sharepoint MOSS WSS 2007 Sviluppo

  7. Yes Kay says:


    It was like a Deja Vu. We went through the same exploration path and chose SmartPart option.

    Additional advantages were

    – Easy to test. User controls can be individually tested in a non sharepoint environment.

    – Portability – Just in case thing – If we decided to abandon sharepoint then easy to switch to traditional dev/deploy without much of code rewrite.

  8. Chris Johnson (Microsoft Consulting Services, New Zealand / TechEd NZ &amp; AU speaker) has written an

  9. Sharepoint MOSS WSS 2007 Sviluppo Development

  10. Этот пост содержит ссылки на важные материалы, c помощью которых можно качественно повысить уровень знаний

  11. Sous SPS 2003, on résume bien souvent le développement SharePoint à "faire des WebParts". MOSS 2007 change

  12. Shailesh says:

    The matrix is really very helpful. My team and I went through a similar exercise, and decided to go the _layouts route, as our need was to use the custom app in many sites. This matrix will serve to be very re-usable in our upcoming projects 🙂

  13. No lo sabia, esta interesante para casos en los que todos los sitios de un sharepoint tienen que usar

  14. Jason says:

    Chris, I am evaluating the same options, but for an external internet portal site.

    Is it possible to use MOSS in a traditional CMS sense, where content and navigation is defined in MOSS, and an external .NET application consumes the sitemap and retrieves content managed field controls using WSS API or Web Services? Of course the external site’s structure would need to mirror the site’s MOSS structure, and would mirror the master page as well.

  15. Adam says:

    Coming from the CMS 2002 world, this is really disappointing if these are the only options.

    It seems like a world of hoops to jump through just to get some basic custom UI functionality into a page on an external site. In CMS, you could intermix content field controls with regular controls, and use code behind to respond to user interaction.  Now, to process any kind of user interaction, I have to create a web part, or user control, or some _layout app.  Just to get a text box and a button for someone to sign up for a newsletter, I have to go and write a custom control.  It just seems ridiculous.

  16. chjohn says:


    You can still just add any ASP.Net code/controls you like direct into web content managed (WCM) pages just like you would in CMS.  My post didnt really point this out … but i was really talking about adding pages to web part pages etc… rather than WCM ones.


    Yes you can get access to all the content via the APIs/Web Services etc…



  17. Adam says:

    Hey Chris,

    Thanks for replying.  Unless I am missing something, I think you may be incorrect about WCM pages.  A WCM page will consist of a combination of a master page, a page layout (.aspx content page that references the master) and a sharepoint "Page", which is basically just an item of data in a sharepoint list. The master pages and page layouts (.aspx pages) are stored in document libraries.

    If you try to add a code behind file to a master page or a .aspx page layout, or even try to use a server side script block &lt;% %&gt; or &lt;script runat="server"&gt;, you’ll get an error from SharePoint that this is not allowed.  While you can drag controls onto those pages, it doesn’t seem like you can write any code behind to interact with them.

  18. chjohn says:

    Hi Adam,

    You are right that you have a masterpage, pagelayout & the actual field control content in the "/pages" list.  So what you can do is either wrap up code and layout in a server control for example and use those anywhere you like on the masterpage or pagelayout.  You are right that by default MOSS will not let you put serverside code in a code block … however you can change this in the web.config file if you want to allow it.  That would allow you to write code to "connect" controls etc… However, I would probably opt for wrapping stuff up in a single control to make things simpler.

    So … you can have server controls with code in them and you can add code behind that interacts with them if you make a change to allow that.

    Hope this helps.



  19. Dino Damalas says:

    You got one other option for creating web applications that I’ve been playing around with.  If you create a web application project (, you can deploy your single assembly to SharePoint’s bin folder and use one of SharePoint’s master page.

    When you create your web application, you need to ensure that you use a master page – any master page will do, but you should ensure that your content page references the same content control ID that SharePoint uses.  In addition, you need to define and implement all your events and their handlers in your code behind and you have to turn off autoeventwireup.  SharePoint freaks if you have autoeventwireup=true or if you have a button or control on your page defines that method that should occur if a button or other event is triggered.  

    Once you’ve created and tested your app (outside of SharePoint), you compile it to single DLL and move it to SharePoint’s bin folder.  Then you have to mark the assembly as safe, much like a web part, in the web.config file.  Then you can just use SharePoint designer to drop your files into a folder of your choice on your SharePoint site.  SharePoint designer will pick up that the master page you have defined does not exist in your SharePoint site and prompt you to pick a new master page.  

    It works… I’ve done it twice.  One last note, if you had any settings or connectionstrings in your apps web.config, you must move those to SharePoint’s web.config.  



  20. Romeo Pruno says:

    VIA Chris Johnson I have been fortunate enough to have been involved deeply with one of our early Office

  21. Ted says:

    In 2003 I created a custom user admin application that sat in the

    _layouts virtual directory and allowed us to customise the user admin

    side of things for our team sites. Now we want to be able to do the

    same thing in MOSS 2007 – only I can’t find any way of making it work.

    According to: it is

    possible. Does anyone have any pointers on creating a _layouts

    Application in MOSS 2007 or preferably is there a how to for doing

    this? My searches for information have all come up blank…

    When I tried building a "Web Application Project" with compiled pages and

    use "publish" to get it to the site (or even just plain old copy), it only

    works from root. When I try to access from a subsite, SharePoint fails on

    trying to load the bin.dll.

  22. I had a commenter suggest another fantasic option for integrating an ASP.Net application with SharePoint.

  23. Jay Arvin says:

    Hi Ted,

    I hope my reply is not yet late.  I also encountered that error and to resolve it.  I put my aspx page in the layouts folder and then put my dll in the bin folder of my top level site.  You need modify the trust level of the web.config of your TopLevelSite to WSS_Medium if ever you are using SharePoint object Model.

  24. Jay Arvin says:

    Hi Chris,

    I tried the steps you mention above in deploying aspx page to sharepoint site. It was working when I only have an event in the page_load but if I have a button with a click_event, the page will encounter an error stating that the event handler ‘OnClick" is not allowed in this page.  Do you know whats causing the error and what needs to be done to resolve it.


  25. Helge Norvang says:

    Has anyone figured out how to add an web application as described in option 4 to a Solution package?

  26. Ole Kristian says:


    I have tried both option number 2 and 4, and I have a problem with not being able to attach to the w3wp.exe process. The breakpoints says "The breakpoint will not currently be hit. No symbols were loaded for this document". I am running my sharepoint site as litwareincok which is member of the administrator group in AD, and is Owner of the Site Collection.

  27. deeptyranjan says:

    Dear All,

    Is there any facility to use external webservices without any coding ?

    If coding is still required, Please let me know the detail steps.

  28. Dolf Steiner says:

    Thank you for describing option 4. I tried it out and it works fine.

    But I got in trouble with the ‘mySite.AllowUnsafeUpdates = true;’ statement in my code behind class, throwing a Security Exception. I tried to deploy my dll to GAC (with Strong Name), but this way, the class isn’t found any more.

    Can you give some hints, how this problem could be solved?



  29. Following on from my post of application dev on SharePoint ( here ), I have had some people ask how to

  30. chjohn says:

    Hi Everyone,

    Jay Arvin:  You need to hook up your event handlers in the code behind.  The autoevent wireup will not work.

    Ole Kristian:  There might be more than one w3wp.exe process.  Try selecting them all and attaching to all of them.

    Dolf Steiner:  You might not be reffering to your assembly in the GAC correctly in the web.config file.  Make sure in the safe controls list you are correctly reffering to your assembly with the correct name etc…  SharePoint should have no problem locating assemblies in the GAC as i have deployed web part assemblies this way before and it has worked.

    Great to see so many people building their apps on top of SharePoint!!!!


  31. Andre Maia says:


    I still cant make a aspx work in sharepoint 2007, i think something is missing in my code, can someone please send me a working aspx project so i can compile and try it in sharepoint.

    My email is or


  32. Gerry says:

    Hi Chris

    I followed the method of opton 4 to create a custom sharepoint page and deploy into SharePoint site. It works perfectly.

    But now I encounter a problem with the selectedindexchanged event of a drop-down list in my custom page. Whenver I choose an item in the drop-down list, the drop-down list does trigger a postback event, but the it does not fire the selectedindexchanged event.

    I have declared the event in page load as below, and yet the selectedindexchanged still does not work.

    this.dropdownlist1.SelectedIndexChanged += new System.EventHandler(this.dropdownlist1_SelectedIndexChanged);

    Please advise.


  33. Nathan says:

    I’m trying to run some custom web application projects using option #4.  I’m stuck with trying to get my user controls which are inside my web app project to be registered as safe controls.  They are in the web app dll so they have been signed and deployed to the GAC.  SharePoint doesn’t like you to drag the ascx pages into designer and use them in your aspx page, and specifying SafeControl for the MyWebApp with TypeName=* doesn’t include the user control evidently.

    MyWebApp.dll has TestPage.aspx/.cs and TestControl.ascx/.cs

    Drag TestPage.aspx and TestControl.ascx

    TestPage.aspx includes an instance of TestControl

    Run TestPage.aspx

    I get an error "An error occurred during the processing of /TestPage.aspx. The referenced file ‘/MyControl.ascx’ is not allowed on this page."

    Any suggestions?

  34. Nigel says:

    I thought web application projects used just in time compilation so there is no dll.  I have installed the Visual Studio 2005 Web Application Projects extension and its pre-requisite and I still dont get a dll !

    Otherwise I have to have a minimal .cs file and compile most of the functionality into a C# class project.

    Have I missed something ?


  35. Blesson Joy says:

    Thanks for the gr8 article.

    I am trying out Option 4 and it seems to work fine. I am having a problem when I use a <WebPartPages:WebPartZone> in the aspx page. I am able to show the page and add webparts to the zone. The problem is when I select Edit Shared Web Part, the edit properties dont show up. Instead I am redirected back to view mode.

  36. mgr says:


    Could any of you who have option 4 working put up a step by step in detail procedur how to do it. I am trying it out but the webpage keeps throwing the error cannot reach the assembly.


  37. nxliu says:

    option 4 is great!

    for option 2, you "can use the ASP.Net master page of the site context" as Serge Van Den Oever suggests:

    after following option 4, i have a problem,  my application page located in subsite, and i have modified the site collection’s web.config file as option 4, when browsing the application page, it says something: you can’t use enablesessionstate in this page.

    because my application page need CAPTCHA image, which required the session to hold the dynamically generate code.  i am wondering if session state is prohibited in sharepoint? if yes, i have to switch the session mechanism for CAPTCHA to non-session mechanism

    the difference is i am using application page in subsite,   i am not sure if i need to create a web.config in sharepoint designer under subsite’s root directory and modify relating config.

  38. Akhlaq Khan says:

    i tried compiling the project you have mentioned in method 4, but it doesn’t compile and i receive following errors:

    Error 1 Validation (ASP.Net): Attribute ‘webpartpageexpansion’ is not a valid attribute of element ‘Page’. C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2005ProjectsWebProject1WebProject1Default.aspx 1 29 WebProject1

    Error 2 Validation (ASP.Net): Attribute ‘progid’ is not a valid attribute of element ‘Page’. C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2005ProjectsWebProject1WebProject1Default.aspx 1 62 WebProject1

    Error 3 Element ‘Content’ is not a known element. This can occur if there is a compilation error in the Web site. C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2005ProjectsWebProject1WebProject1Default.aspx 11 10 WebProject1

    Error 4 Element ‘Label’ is not a known element. This can occur if there is a compilation error in the Web site. C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2005ProjectsWebProject1WebProject1Default.aspx 14 6 WebProject1

    Error 5 C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2005ProjectsWebProject1WebProject1Default.aspx: ASP.NET runtime error: Only Content controls are allowed directly in a content page that contains Content controls. C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2005ProjectsWebProject1WebProject1Default.aspx 3 1 WebProject1

    Warning 6 Generation of designer file failed: Only Content controls are allowed directly in a content page that contains Content controls. C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2005ProjectsWebProject1WebProject1Default.aspx 5 0 WebProject1

    Error 7 The name ‘Label1’ does not exist in the current context C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2005ProjectsWebProject1WebProject1Default.aspx.cs 18 13 WebProject1

    Error 8 The name ‘SPContext’ does not exist in the current context C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2005ProjectsWebProject1WebProject1Default.aspx.cs 18 27 WebProject1

    can someone help? 🙁

  39. JJ says:

    Great blog, however, I have had tough luck applying the solutions. My task is to put existing and newly created web applications under SharePoint (MOSS 2007). They are supposed to be accessible by some users only. I tried options 3 and 4 and failed:

    Option 3 (SmartPart). Watched the screen cast, followed the instructions and it fails when adding the SmartPart webpart with "unable to import webpart", or something to that effect. Any ideas?

    Option 4. Compiler does not like attributes webpartpageexpansion and progid (same as error 1 and 2, Akhlaq). What references are missing?

    How about standard "Page Viewer Web Part"? Just created a mockup of our new application in VS 2005 and deployed using it. The application contains several screens in several directories, all kinds of controls, forms authentication, etc. Copied the whole thing into the SharePoint directory structure (like in option 2), defined virtual directory, and it works! But there is the concern whether it is fully integrated into SharePoint, the workflows, etc?

  40. nxliu says:

    Another problem i encountered is after drag the aspx file into a folder in sharepoint Designer, it is browsable using windows authentication, when enabled anonymous access,  the page is inaccessible, not sure how to set the security on the folder for application pages, and is the folder just a folder or Document library?

  41. Jason says:

    Hey there.  I’m mega new to anything sharepoint (in any version) , so hopefully this issue is something simple and obvious for those with more sharepoint experience.

    I followed option 4, created a little hello world page, plopped it on my VM containing Sharepoint, into my site, in a new directory, and conducted all the other steps.  It would work fine except the MasterPageFile token set in the MasterPageFile attribute in this new page is not being processed correctly and is throwing an error saying "The file "/MyNewFolder/~master/default.Master" does not exist.  I have the MasterPageFile attribute set to "~masterurl/default.Master", and based on that message, it makes me think Sharepoint is not processing the MasterPage and is literally trying to find a file with that name.

    So, what am I missing here? thanks

  42. Baddy says:

    In Option 4 I can’t compile project. I have the same problems like Akhlaq Khan. I use WSS 3.0 and VS2005 sp1 with all Extensions. Please, help me!

  43. m naeem khan says:

    i have another issue

    do you have any solution for this

    i want to make a site with new layout outs which have some custome pages(aspx) some list new master page and so one also i need to build it through one click deployment.

    mean that is there any way to make a pacakage through which i can a installable file which configured my site defination custom pages and dll to the moss existing site or make a new top level site?

  44. NHandberry says:

    Has anyone gotten option 4 to work with an application that uses session state yet?  If so please post the solution.

    It seems all the writeups on session state errors with WSS have to do with upgrades  to WSS or using reporting services with WSS.  The problem with the fixes I’ve seen for these approaches is that they exclude the path to the application in Central Admin from WSS and I need my application to run under the WSS context.  I want to grab the identity of the user from SharePoint to use as a key for pulling other data in my custom .Net applications.  I am using the SharePoint web.config and have set enableSessionState="True", the http module is there for System.Web.SessionState, and the session state node is set to inProc.  I’ve deploye the applications to the SharePoint box outside of wss and they work fine, but then I can’t get the Identity of the logged in user.

    This is the error I get when I run my application in SharePoint.  

    Unexpected Exception – Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \ section in the application configuration.

  45. NHandberry says:

    I figured out the session state problem.  I added a page parser path, seems to fix a lot of the errors I was receiving.


    <PageParserPath VirtualPath="/pages/test.aspx" CompilationMode="Always" AllowServerSideScript="true" />


  46. Pwisz says:

    Does anyone know where I can find SmartPart v3?  The GotDotNet site has removed it, and everywhere I look links to the GotDotNet site.

  47. Marek Hlavac says:

    I tried it and this are the results. Whats wrong???

    Error 1 Validation (ASP.Net): Attribute ‘webpartpageexpansion’ is not a valid attribute of element ‘Page’.

    Error 2 Validation (ASP.Net): Attribute ‘progid’ is not a valid attribute of element ‘Page’.

    Error 3 Could not find ‘PlaceHolderMain’ in the current master page or pages.

    Error 4 The name ‘Label1’ does not exist in the current context

    Error 5 The name ‘SPContext’ does not exist in the current context

  48. NHandberry says:

    Ok, I got through the session state issue by correctly defining the PageParserPaths.  Now I’m stuck on getting my popups to display correctly.  I get the message:

    "This Page has been modified since you opened it. You must open the page again."

    I’ve been working on this for a while now.  I have an application with a parameter screen and I click a button.  That button opens up a report in a new window with an ObjectDataSource bound to it.  The report screen gets the values using Page.Previous to get the parameters selected on the parameter screen.

    I created a smaller test application using virtually the same stripped down code.  It worked the first time I deployed it.  Then I pushed out a new build and replaced my aspx files.  I ran it again and then I got the same error "This Page has been modified since you opened it. You must open the page again."  This means I reproduced the error with the stripped down code.  I am now able to redeploy my sample application after clearing out everything that has to do with the project and then redeploying it.  I am running both applications in the same directory of the same site.  I tried completely clearing out my real project and redeploying it, but I still got the same error.  My best guess is it might have something to do with publishing the files using a publishing portal site and having them in some kind of modified state, so it thinks they have been changed.  Any suggestions on what might cause this error?

  49. Until yesterday it has been quite a while since I blogged. Basically here is the list of things I have

  50. Until yesterday it has been quite a while since I blogged. Basically here is the list of things I have

  51. sultanofmoss says:

    Chris ,

            Can you provide me Code for protocol Handler in MOSS


  52. Ankit says:

    Hi Chris,

    I tried the steps mentioned above for  integrating ASP.NET pages in MOSS or Share Point 2007. I think that some steps are missing or reference for building the project.Could you please update it with detail steps.

    Actually i am facing an issue , I have custom .NET application built in 1.1 and I need to move all these functionality to MOSS 2007, will it be wise to convert everything to web part or some sort of navigation to be provided to custom .NET application from Share Pont . Actually these custom .NET application are accessed based on roles and rights that we are gathering while when the user logins authenticating against custom database. Is there any way i could pass session value (like login credentials) of user to Custom .NET application while redirecting from Share Point?

    It would be nice if you could suggest something.

    Thanx in advance.


  53. nemortu says:

    Hi Chris,

    I was trying to use a custom built Web Part that would rely on a basic event list on my MOSS server (for storing all events). From my custom web part I can easily get the filtered items from the event list (using a querry in C#) but the problem I’m facing theese past days is to display theese items in a MOSS "like" calendar. I searched like crazy for a doc on how to use/customize the OOB controls/../views but I just cant seem to find how to do it. Could you give me a link to where I could find some usefull docs on how to use a lSPCaendarView for instance. The MSDN API doc (which is in fact same as the sdk chm), is you can call it a doc, just gives a basic listing of properties/methods, without even saying what they are used for. My custom web part is intended to be used for searching events from an existing list and displaying them in a calendar view (if it could be done by modifying the ListWiewWebPart it would really be great but since it’s sealed …. I don’t think it’s possible). Any help/suggestion would be greatly appreciated.



  54. Application Development on MOSS 2007 & WSS V3

  55. Michael says:

    "This Page has been modified since you opened it. You must open the page again."

    This is the message in sharepoint error page. Help.

  56. BowlOfChilli says:

    Is the placing of the page in the directory through sharepoint designer necessary. Can I do it without using the designer?.

  57. Ling says:


    I have tried option 4, which run ok, but now i am having problem connecting to sql server. i can connect to sql server in IIS server.

    client machine -> IIS server -> sql server.

    any suggestion.


  58. Vishu says:


    I tried option 4 and it worked great!. but it was tried with C#. When I try the same with VB.Net, it fails:

    1. Created a master page and imported the same into the Sharepoint site using the SPD

    2. Created a content page using my master page and imported the same into my website using SPD

    3. Made my master page as the custom master page

    4. Modified the content page to refer ~masterurl/custom.master for master page

    5. Copied the code-behind DLL in ..80bin directory

    6. Added it to the safe controls list

    (Remember, all these things are done in VB.Net)

    When I try to preview the content page from SPD, it fails at the first line in the code-behind which assigns some value to a Label control. Interestingly the Label control is uninitialized and hence I get a NullReferenceException. The same exact thing, if written in C#, works great but fails with VB.Net. Anyone has any idea?



  59. m_vishu says:

    Does MOSS have seamless support to VB.Net?

  60. AndyI says:


    I have tried to attach to our virtual server using VST02005 and I am unable to get the machine to show.  I have been able to map drives to it, and access the url.  I also can not find the machine if I try to browse to it.  Has anyone else had this problem and solved it?



  61. MG says:


    Even I tried using VB.NET and it didn’t work. The same steps work for C# when I am using Option 4. It is a very clean of integrating legacy web applications, but there is no point to convert them in C# before integrating with Moss. Has anyone successfully tried it??



  62. Madhukaran says:


    I integrated dotnet appliation into sharepoint

    There are some problems i’m not able to solve.

    Please can i get the solution for the following

    1. In the dotnet application i’m using email sending where email attachment is not working.

    2. When I’m using classes in App_Code folder, site doesn’t work

    Thanks & Regards


  63. Chris says:

    Great post.  Two more advantages of option #3 over #4 are

    1 )The ability to intermingle your custom stuff with native sharepoint web parts such as document libraries and content editor web parts.

    2) Losing the "building-block" effect of web parts like allowing the administrator to re-arrange the page layout (web part zones) without requiring developer effort.

  64. Aaron says:

    Option 4 can be more sucure if you strong name your build

    no one really wants to lower security (but we do if we hafta!)

    <trust level="WSS_Minimal" originUrl="" /> line to <trust level="WSS_Medium" originUrl="" />

    strong name and use the key in the web.config

    <SafeControl Assembly="test, Version=, Culture=neutral, PublicKeyToken=0123456789abcdef" Namespace="test" TypeName="*" Safe="True" />

    and if you want to use them on more then 1 site, GAC them, then you dont have to put them in every bin

  65. useful links for sharepoint 2007 customization

  66. chjohn says:

    Hi Everyone,

    Thanks for all the comments!  It is great to see so many people getting into SharePoint application development.

    I have just updated the post.  I updated Option 4 with some verified steps sent to me by one of our fellow readers Michal Gwozdek.  These steps work well for him and there are some variations on my original post in there.

    Thanks a bunch Michal!


  67. TigerBlog says:

    I tried option 4 and it worked great

  68. Hi Everyone says:

    I am trying to clean up this website and &amp; and other expressions that let browsers see the site without errors. Is there a reference anywhere for these terms? Specifical the ‘ and space, .$

  69. Rollercodester says:

    Simply awesome!

    Thanks for the contribution and thought leadership on this subject.

  70. Introduction This is the first in a series of posts on how to build various types of applications on

  71. Rollercodester says:

    This may be a little off-topic…but one drawback on the subject of being able to automagically integrate external ASP.NET applications within a SP2007 site is the unfortunate inability to run the external application in its own app pool.  The common workaround is the use of IFRAMES within SP, which of course has many shortcomings.  Option #4 is a sweet solution to the IFRAME problem, only now we have to worry about external applications bringing down the site with poor code that is not directly under our control.  Still, with a proper application integration/code review process, this can be mitigated.

    I’m curious to hear your thoughts on bringing in multiple (dozen or more) external applications into a single SP portal site via Option #4?  Is gaining the automatic enforcement of the site’s master page and access to the SP context worth the risk?  

    Running an ASP.NET app isolated used to be mandatory in the enterprise, but with SP/ASP.NET 2.0, I’m not sure how much of this is still a concern?  I assume it’s as important as ever…or is it?

    Also, if I’ve missed the mark, and there is a way to have an external app run with its own app pool via Option #4 (or similar approach), please educate me.  Requirements here being we want automatic master page reuse (without forcing external app to use our master page directly) and access to the portal’s SharePoint context (less important).

    Thanks In Advance!

  72. Mark Mills says:

    I’m concerned that MS is not putting enough emphasis on setting up security correctly for a MOSS 2007 infrastructure.  It seems no training classes or documentation clearly defines what permissions are given to Local svr groups, Domain Svr Groups, and to SQL Account Logins to each database created in SharePointMOSS.  

    For example MS recommends what appears to be 13 seperate accounts to set up a secure Sharepoint Infrastructure- don’t beleive me, see    

    If your a SharePoint Administrator I’ve created 2 spread sheets that document the security assigned to each "MS recommended" account at all 3 levels: Local svr groups, Domain Svr Groups, and the SQL Account Logins to each database, HOWEVER, I don’t have the expertise yet to finish filling it out.  I can send you a copy up on request.

    Is there anyone who has used MS’s lease security principle when setting up their SharePointMOSSProject 2007 Svr environment?  Who has the knowledge to fill complete the MOSS 2007 security spreadsheet?

    Mark Mills

    Mr M Mills1@

    Sr. MS Systems Engineer

    Houston TX


  73. GR says:

    I tried option 4 in the above mentioned.

    I created dll and copied to sharpoint root bin folder.

    Also copied aspx page to the site where I need.

    I receive error message saying "An unexpected error has occurred". I can not debug. Because I do not see w3wp.exe process.

    Any one please help me to fix this.

    Thanks in advance,


  74. GR says:

    I tried in VB the option 4.

    This is exactly what I need. Great!.

    But It doesn’t work, the same as mentioned in step4, no changes at all except in VB. Any body having any suggestions please?

  75. Thanks for sharing your thoughts.

    Its really a nice post!

  76. RR says:

    For those having trouble with option 4; I had to give it a strong name and add it to the GAC

  77. nimi says:

    I have data in a SQL table. I want to display this data on a sharepoint site in such a way that data can be modified in the table, through the site (use the site to add data or modify existing data). after loads of readig and research, i only seem to get to know that it is not possible. is it true that Sharepoint sites cannot be connected to SQL dbs or tables directly. Any change in the table is not directly reflected on the site.

    TO display data from a table on the site, i used BDCMetaMan to get an XML of the table and add that to the application as BDC.

    Is there any other better way of doig this?

  78. chjohn says:

    Hi nimi,

    You should investigate the DataForm web part.  It will allow you to do what you are looking for.

    Check out the "Build composite no-code SharePoint applications" video here:


  79. michael says:

    I have created a webpart that loads multiple usercontrols I place them and reference them from /_controlTemplates/MyDir this works fine. The webpart loads and i have full control.

    The thing i dont understand is this… I have two projects the webpart itself and a VS2005 "Web Application" that encapuslates all my usercontrols inside a single DLL. My on build events place the usercontrols inside the above mentioned dir on the server. I register my single dll as a safe control and my webpart works perfectly. However, I get an error in the event viewer saying "Error intializing Safe Control" I can not figure why I keep getting this eror r. Once again, aside from the error the webpart works great.

  80. Amit Kshirsagar says:

    Hi everybody,

    I am developing one business application using MOSS.

    I am having two options for storing business data:

    1) MOSS custom list

    2) SQL server 2005 tables

    If I use MOSS custom list,it will break data integrity of business data tables as I can not use Primary key and foreign key relationship on custom list.

    If I use SQL server 2005 tables for storing business data,I can not use in build MOSS functionality like Work flows,custom list etc.

    Is there any other better way of doig this?

    Thanks in advance.

  81. amitnkshirsagar says:

    Hi everybody,

    I am developing one business application using MOSS.

    I am having two options for storing business data:

    1) MOSS custom list

    2) SQL server 2005 tables

    If I use MOSS custom list,it will break data integrity of business data tables as I can not use Primary key and foreign key relationship on custom list.

    If I use SQL server 2005 tables for storing business data,I can not use in build MOSS functionality like Work flows,custom list etc.

    Is there any other better way of doig this?

    Thanks in advance.

  82. Shivendra says:

    15. Open your site in SharePoint Designer and drag and drop your SamplePage.aspx page into a folder in your site.

    This means i need to  open web application that is in iis virtual diractory, and there i have to create one folder as we want , and placce the pages developed in

    please correct me .

    i am new in sharepoint development.


  83. says:

    I am trying to use method 4. To get past ERROR #1 (see below), I had to copy the ~masterurl folder to the application folder on the server (…81binItDoesWork). In step 4 of option 4 (create "~masterurl" folder), am I correct that the folder should be created within my project folder (ItDoesWork)? I am using VS2008. Do I need to copy the default.master to somewhere else on the server, and if so, where on the server?

    ERROR #1:

    Parser Error Message: The file ‘/itdoeswork/~masterurl/default.master’ does not exist.

  84. says:

    For method #4, I have not been able to do step #14: "Change the <trust level="WSS_Minimal" originUrl="" /> line to <trust level="WSS_Medium" originUrl="" />". I assume the correct syntax is "<trustLevel="WSS_Medium" originUrl="" />", but this does not work as "originUrl" is not valid. So, I signed the code and specified the key, etc. in SafeControl, and left the securityPolicy as shown below. This normally works for me. Now I get a security exception (ERROR#1 below). Suggestions?


         <trustLevel name="WSS_Medium" policyFile="C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12configwss_mediumtrust.config" />

         <trustLevel name="WSS_Minimal" policyFile="C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12configwss_minimaltrust.config" />


    ERROR #1:

    Exception Details: System.Security.SecurityException: Request for the permission of type ‘Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ failed.

  85. says:

    Naturally, right after I post my questions, I get it to work 🙂

    The security exception was being caused by the code in the SamplePage.cs file. I commented-out the line (see below – second line works), and it now works. However, since I am new to sharepoint, please reply if you know why the code was triggering the security exception (I need to learn).

    //Label1.Text = SPContext.Current.Site.Url;

    Label1.Text = "changed by code-behind";

  86. Pinky says:

    I want to use AJAX in a user control deploy it in a site page using son of smart part, place the scriptmanaget in PlaceholderMain of the page. But I am getting an error "Only one instance of a ScriptManager can be added to the page.".

    Can anyone help me how to resolve this?

  87. Ulises says:

    I’m also getting the error message :

    The file ‘/itdoeswork/~masterurl/default.master’ does not exist.

    I don’t have SharePoint Designer installed in my computer so I copied the page .aspx to the share point application (I didn’t add the master page or the code behind page)

    I would appreciate if you could help me figure out what I’m doing wrong.

    ureyes84 at gmail dot com

  88. Firoz Ozman says:

    If you get an "error occurred, contact the admin" message, you want to check if there if <form> element in the aspx page. Eliminate the <form> element as it is getting duplicated when it is ported to MOSS.

    For a detail step by step walkthrough, check out

  89. Kevin O'Reilly says:

    Instead of:

    public partial class SamplePage : System.Web.UI.Page

    on the SamplePage.aspx’s code behind, I’d recommend:

    public partial class SamplePage : Microsoft.SharePoint.WebPartPages.WebPartPage . When updating a list using the original code I kept getting sharepoint security errors such as "The security validation for this page is invalid." I switched to the second line and didn’t even need to use SPWeb.AllowUnsafeUpdates = true; to save to the list. Any one see an issue with changing this?

  90. chris_thanks says:



  91. fstumpp says:


    I used option 4 to develop/copy samplepage.aspx into the page library of a publishing sub site below the site collection top site.  

    Using right click "Preview in Browser" in SPD, the page works.  It continues to work as long as I navigate within the site.  

    However, if I go to the top level site and navigate back to my sub site, the samplepage fails to load with the following error – "An error occurred during the processing of . Could not load type ‘ItDoesWork.SamplePage’."

    Any ideas?

    Thx Fred

  92. fstumpp says:


    Please disregard my previous "I used option 4 to develop/copy samplepage.aspx …".  

    I have two wfe servers in my new development environment, and neglected to copy the dll to the bin of the second server.  Everything was fine if I accessed and stayed on the first server, but the page failed when NLB sent me to the other server.



  93. Jalil Sear says:

    Pardon my ignorance on this maybe I am missing the point completely but wouldnt it be easier to deploy your custom pages by programmatically adding them to the pages splist?

    I basically, had a simple .aspx page with a user control. I deployed it via this method.

  94. Ryan Greenaway says:

    Hi Chris,

    I am a sharepoint Newbie and had been really struggling to get to grips with code behind files in Sharepoint (or lack of).

    Your step by step guide was perfect.

    However, I was wondering if there is anyway you could do something in the same format for implementing code behind in masterpages (preferably in VB). I have been trying to follow Andrew Connell’s guide on MSDN but there are evidently gaps in my knowledge that are exposed by his explanation as it just seems to trail off to leave me in confusion. Any help you can give on this is much appreciated.


  95. Sucheta says:

    Hi Chris,

    I was able to develop a custom application for my Share Point site using Option 4. Just one question here. I need to read some configuration values (user defined) from web.config from the appsettings section. So in the Option 4, do I need to insert the appsettings element (with key and value) in the web.config of the virtual dir for that site? Is there any better option? Also how can I use session variables? I need to pass a complex object from one page to the next…


  96. Zach says:

    People trying option #4:

    You have to create the project in C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATELAYOUTS.

    If you create a project called Test then it will go to C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATELAYOUTSTest

    To view it in share point just http://localhost/[Any Site Name You Want]/_layouts/Test/default.aspx

    You may have to remove the authentication=windows in this apps web.config

  97. alex k bcn says:

    Hi! very nice post. Im currently trying to figure out how I can publish existing applications to a newly built WSS server. This post really helped me to know what to look for!

    Thank you.


  98. Drew Milne says:

    Hey there,

    This is a great post, and im keen to use option #4, but unfortunately my coding experience is with and not c.

    Has anyone developed the suggested version #4 using If they have it would be great if they could post an example here and expand a little one what Chris said.

    I.e Im confusd by point 5 ie – "Replace code behind for the masterpage with:" does this mean put this code in the Default.aspx file? as I cant see it being placed in the imported .master file.

    Thanks in advance.

  99. J says:

    Zach, puting it into the Layouts folder is part of an entirely different solution.  The Layouts folder is virtualized across all sites, and is not ideal for some situations.

    #4 is a way to have a single instance of an application.

    The grid in the original posts illustrates this.

  100. Error:  The Master Page file ‘~masterurl/default.master’ cannot be loaded.  Correct the problem in Code View

    I was receiving the above error when trying to “edit” my SamplePage.aspx from example 4 with the VS 2008 “design mode” tools.  It worked fine when deploying to SharePoint as described in the article.

    This is because the ~masterurl code in SamplePage.aspx and the ~masterurl folder name, refers to a “virtual server” location, not the actual “file structure” location.

    So, for using the VS tools in Design mode, you need to change the ~masterurl to just masterurl (notice the tilde is gone) in both the SamplePage.asxp and the folder name.  Then, you can use the “Design” mode within VS to layout your page/add controls, etc.

    When you deploy to SharePoint, just switch these items back.

    Hope this helps.

    Aaron Wiggans

  101. Anoop Sihag says:

    Decision matrix help me to choose the correct option. It’s very nice post.

    In my case i am using option 4.

  102. Greg Developer says:


    here is a tutorial for adding custom codebehind to sharepoint aspx page, especially masterpage.

    if you want, take a look on it – <a href="">Masterpage with codebehind</a>

  103. Kailash Sohoni says:

    Option 4 was brilliant! Thanks to you and Michal Gwozdek for this.

    I wonder if an app can run inside MOSS but built and deployed using WSPBuilder.

Comments are closed.

Skip to main content