Welcome to MSDN Blogs Sign in | Join | Help

Chris Johnson

All about Chris Johnson, SharePoint Products & Technologies & Other Stuff.
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.

Pros:

  • 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

Cons:

  • 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.

Pros:

  • 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.

Cons:

  • 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: http://www.smartpart.info/default.aspx
(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)

Pros:

  • 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).

Cons:

  • 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>

</asp:Content>

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.

C:\Inetpub\wwwroot\wss\VirtualDirectories\moss.litwareinc.com80\bin

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.

C:\Inetpub\wwwroot\wss\VirtualDirectories\moss.litwareinc.com80\web.config

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.

http://moss.litwareinc.com/TestApp/TestPages.aspx

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.

Pros:

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

Cons:

  • 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 ...

-Chris.

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

Posted: Tuesday, September 05, 2006 5:08 PM by chjohn

Comments

Angus Logan's Portals Blog said:

Chris Johnson (Microsoft Consulting Services, New Zealand / TechEd NZ &amp;amp; AU speaker) has written an...
# September 5, 2006 4:51 AM

Robin said:

That decision matrix is very handy! Thnx :)
# September 6, 2006 4:35 AM

The Boiler Room - Mark Kruger, SharePoint MVP said:

Here is an assortment of various 2007 Microsoft Office SharePoint Server Documentation / Reference Materials...
# September 7, 2006 5:58 PM

Mike Walsh's WSS and more said:

# September 10, 2006 3:10 AM

Chris Johnson said:

Background:
Anyone who is familiar with development &amp;amp; deployment of custom solutions on SharePoint...
# September 10, 2006 10:23 PM

Technical Weblog of Eric Charran said:

Chris Johnson posted a great article on the options for conducting UI application development in MOSS...
# September 18, 2006 10:41 PM

Tecnologie .NET (Dotnet) said:

Sharepoint MOSS WSS 2007 Sviluppo
# September 19, 2006 5:24 AM

Yes Kay said:

Chris,

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.

# October 26, 2006 3:12 PM

Angus Logan's Portals Blog said:

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

# October 28, 2006 10:36 PM

Tecnologie .NET (Dotnet) said:

Sharepoint MOSS WSS 2007 Sviluppo Development

# November 10, 2006 2:51 AM

dmandreev's WebLog said:

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

# December 6, 2006 8:56 PM

The Mit's Blog said:

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

# December 20, 2006 6:23 AM

Shailesh said:

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 :-)

# January 7, 2007 10:07 PM

Be Geek My Friend said:

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

# February 5, 2007 12:44 AM

Jason said:

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.

# February 6, 2007 9:34 PM

Adam said:

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 asp.net 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.

# February 15, 2007 4:03 PM

chjohn said:

Adam,

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.

Jason,

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

Thanks,

Chris.

# February 15, 2007 4:23 PM

Adam said:

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 asp.net controls onto those pages, it doesn't seem like you can write any code behind to interact with them.

# February 15, 2007 4:57 PM

chjohn said:

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.

Thanks,

Chris.

# February 15, 2007 5:17 PM

Dino Damalas said:

You got one other option for creating web applications that I've been playing around with.  If you create a web application project (http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx), 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.  

Thanks,

Dino

# February 27, 2007 9:55 PM

Johnwe's SharePoint WebLog said:

http://blogs.msdn.com/cjohnson/archive/2006/09/05/740498.aspx Chris Johnson has a good write up on different

# March 1, 2007 11:49 AM

Romeo Pruno said:

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

# March 1, 2007 4:52 PM

Ted said:

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:

http://blogs.msdn.com/cjohnson/archive/2006/09/05/740498.aspx 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.

# March 7, 2007 6:01 PM

Chris Johnson said:

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

# March 15, 2007 12:27 AM

Jay Arvin said:

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.

# March 21, 2007 7:26 AM

Jay Arvin said:

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.

Thanks!

# March 21, 2007 7:33 AM

Helge Norvang said:

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

# March 22, 2007 5:47 AM

Ole Kristian said:

Hi

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 litwareinc\ok which is member of the administrator group in AD, and is Owner of the Site Collection.

# March 23, 2007 4:13 AM

deeptyranjan said:

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.

# March 23, 2007 6:12 AM

Dolf Steiner said:

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?

Thanks

Dolf

# March 23, 2007 9:32 AM

Chris Johnson said:

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

# March 27, 2007 8:06 PM

chjohn said:

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!!!!

-Chris.

# March 28, 2007 5:57 PM

Andre Maia said:

Hi.

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 andre_maia24@hotmail.com or andremaia2005@gmail.com

Thks!!!

# March 29, 2007 6:37 AM

Gerry said:

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.

Thanks!

# April 1, 2007 4:36 AM

Nathan said:

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?

# April 10, 2007 5:57 PM

Yoel said:

# April 11, 2007 6:52 AM

Nigel said:

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 ?

Thanks

# April 11, 2007 10:27 AM

Blesson Joy said:

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.

# April 11, 2007 4:40 PM

mgr said:

Hi,

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.

thanks

# April 12, 2007 2:47 PM

nxliu said:

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:

http://weblogs.asp.net/soever/archive/2006/11/14/SharePoint-2007_3A00_-using-the-masterpage-from-your-site-in-custom-_5F00_layouts-pages.aspx

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.

# April 16, 2007 1:32 AM

Akhlaq Khan said:

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 Settings\Administrator\My Documents\Visual Studio 2005\Projects\WebProject1\WebProject1\Default.aspx 1 29 WebProject1

Error 2 Validation (ASP.Net): Attribute 'progid' is not a valid attribute of element 'Page'. C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\WebProject1\WebProject1\Default.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 Settings\Administrator\My Documents\Visual Studio 2005\Projects\WebProject1\WebProject1\Default.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 Settings\Administrator\My Documents\Visual Studio 2005\Projects\WebProject1\WebProject1\Default.aspx 14 6 WebProject1

Error 5 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\WebProject1\WebProject1\Default.aspx: ASP.NET runtime error: Only Content controls are allowed directly in a content page that contains Content controls. C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\WebProject1\WebProject1\Default.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 Settings\Administrator\My Documents\Visual Studio 2005\Projects\WebProject1\WebProject1\Default.aspx 5 0 WebProject1

Error 7 The name 'Label1' does not exist in the current context C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\WebProject1\WebProject1\Default.aspx.cs 18 13 WebProject1

Error 8 The name 'SPContext' does not exist in the current context C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\WebProject1\WebProject1\Default.aspx.cs 18 27 WebProject1

can someone help? :(

# April 17, 2007 12:59 PM

JJ said:

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?

# April 20, 2007 1:27 PM

nxliu said:

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?

# April 25, 2007 8:43 AM

Jason said:

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 asp.net is literally trying to find a file with that name.

So, what am I missing here? thanks

# May 18, 2007 10:41 AM

Baddy said:

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!

# May 30, 2007 9:26 AM

m naeem khan said:

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?

# June 15, 2007 2:27 AM

NHandberry said:

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.

# June 27, 2007 4:39 PM

NHandberry said:

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

http://blogs.msdn.com/kaevans/archive/2007/04/26/code-blocks-are-not-allowed-in-this-file-using-server-side-code-with-sharepoint.aspx

<PageParserPaths>

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

</PageParserPaths>

# June 29, 2007 10:53 AM

Pwisz said:

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

# July 3, 2007 9:43 AM

Marek Hlavac said:

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

# July 3, 2007 11:16 AM

NHandberry said:

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?

# July 3, 2007 4:36 PM

Chris Johnson said:

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

# July 19, 2007 2:01 PM

Noticias externas said:

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

# July 19, 2007 2:07 PM

sultanofmoss said:

Chris ,

        Can you provide me Code for protocol Handler in MOSS

Thanks

# July 20, 2007 7:39 AM

Ankit said:

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.

Ankit

# July 23, 2007 6:49 AM

nemortu said:

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.

regards,

nemortu

# July 26, 2007 6:38 PM

bedroom sex cam said:

Application Development on MOSS 2007 & WSS V3

# August 2, 2007 8:26 AM

Michael said:

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

This is the message in sharepoint error page. Help.

# August 22, 2007 3:48 AM

BowlOfChilli said:

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

# August 24, 2007 4:22 PM

Ling said:

Hi,

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.

Thanks.

# August 27, 2007 6:47 PM

Vishu said:

Hi,

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 ..80\bin 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?

Thanks

Vishu

# September 13, 2007 6:00 AM

m_vishu said:

Does MOSS have seamless support to VB.Net?

# September 13, 2007 11:55 PM

AndyI said:

Hi

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?

Thanks

Andy

# September 17, 2007 8:45 AM

MG said:

Hi,

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??

Thanks,

MG

# October 8, 2007 12:49 PM

Madhukaran said:

Hi,

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

Madhukaran

# October 11, 2007 5:38 AM

Chris said:

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.

# October 19, 2007 7:36 PM

Aaron said:

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=1.0.0.0, 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

# November 7, 2007 2:00 PM

Placelight Blog said:

useful links for sharepoint 2007 customization

# November 8, 2007 11:03 AM

chjohn said:

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!

-Chris.

# November 16, 2007 1:05 PM

TigerBlog said:

I tried option 4 and it worked great

# November 29, 2007 10:46 PM

Hi Everyone said:

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, .$

# December 6, 2007 7:32 AM

Rollercodester said:

Simply awesome!

Thanks for the contribution and thought leadership on this subject.

# December 10, 2007 7:01 PM

Chris Johnson said:

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

# December 14, 2007 3:59 PM

Rollercodester said:

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!

# January 2, 2008 2:47 PM

Mark Mills said:

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 SharePoint\MOSS.  

For example MS recommends what appears to be 13 seperate accounts to set up a secure Sharepoint Infrastructure- don't beleive me, see http://go.microsoft.com/fwlink/LinkID=92883&clcid=0x409    

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 SharePoint\MOSS\Project 2007 Svr environment?  Who has the knowledge to fill complete the MOSS 2007 security spreadsheet?

Mark Mills

Mr M Mills1@ Yahoo.com

Sr. MS Systems Engineer

Houston TX

832-748-1156

# January 9, 2008 2:54 PM

GR said:

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,

GR

# February 14, 2008 3:06 PM

GR said:

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?

# February 15, 2008 3:15 PM

Austin-Software Development Company said:

Thanks for sharing your thoughts.

Its really a nice post!

# February 25, 2008 5:41 AM

RR said:

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

# March 24, 2008 5:43 PM

nimi said:

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?

# March 25, 2008 1:47 PM

chjohn said:

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:

http://office.microsoft.com/en-us/sharepointdesigner/HA102199841033.aspx?pid=CH102201271033

-Chris.

# March 25, 2008 2:11 PM

michael said:

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.

# April 1, 2008 3:22 PM