Monday, December 3, 2012

Adding an ASP.NET 4.0 application to a subdirectory on SharePoint 2010

My SharePoint 2010 site is running under SSL, and I have some web applications I want to keep as separate applications (aka, not publish them to SharePoint), and just have a web part page with a web page viewer.  This way, the page is harnessed within SharePoint, so it still has my SharePoint header\navigation, but its only showing a web application from

For setting this up, most of this was straightforward in that we had to create an "application" in IIS (7.5) underneath my SharePoint site, but I quickly hit a snag.  SharePoint 2010 runs under an ASP.NET 2.0 application pool.  Since 2.0 is old, I wrote my application in 4.0, so my parent (SharePoint) site is 2.0, but the child application is 4.0.

The issue here is that some settings\configurations are loaded because of the 2.0 framework, and launching the 4.0 framework application is also trying to inject similar settings, causing all hell to break loose (OK, just an error page.. but a sternly written one I must say).  To resolve, I did quite a bit of googling, and a little bit of loose translating from here:

In short, if you have to add a .NET 4.0 application as a sub-application to your SharePoint 2010 implementation, start with the usual steps, which are: 
  • Create a new application pool targeting the 4.0 Framework. 
    • If possible, give this the same identity to run under that your SharePoint site is running as. 
  • Then, create your directory on the server that will host your 4.0 application, and link to it within IIS (right-click the SharePoint web and click Add Application). 
  • Go ahead and deploy your application, and try to browse to it. 
If your in a similar spot than I, then you should have an error message similar to a 500.19, barking about a configuration error and that there is a duplicate <somethingOrOther> section defined.  To resolve...

  1. In your sharepoint web.config, we need to prevent inheritance of parent (sharepoint) settings, I surrounded system.web with:
    <location inheritInChildApplications="false" path=".">
  2. Also within our SharePoint config, I commented out the system.web.extensions section group (and everything within it), and added it to the .NET framework's 2.0 web.config, found at c:\windows\\framework64\v2.0.50727\config\web.config
  3. I then added the following to the modules section to my application's config file, to prevent these modules from inheriting
    <remove name="SPRequestModule"/>
    <remove name="PublishingHttpModule"/>
    <remove name="RSRedirectModule"/>
    <remove name="StateServiceModule"/>
    <remove name="SharePoint14Module"/>
At this point, I was still getting 500 error's, but the error message wouldn't even display for me.  Much like the aforementioned article, I had to enable Failed Request Tracking in IIS.  Once I did so, I found that the following error was occurring:
"Handler PageHandlerFactory-Integrated has a bad module ManagedPipelineHandler in its module list. 

Some more googling led me down the path that the 4.0 Framework wasn't installed properly.  That didn't make much sense to me, but it was easy enough to open a command line and execute: %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
Once I did so, my application started working.  Hope this helps!

No comments:

Post a Comment