Sharing SharePoint 2010 and ASP.NET 4.0 User Credential

Many people have their custom ASP.NET application embedded as a IFRAME inside SharePoint. When you do this, you might also want to take advantage of creating a ‘Single Sign On’ experience for your users so that the ASP.NET doesn’t challenge the user for password again. You can make use of SharePoint SSO to achieve this but if you are using SharePoint 2010 Foundation you will run into problem so this is a solution I found online that works.

I got the guide from this French blog and got Google to translate for me. Certain parts are not clear [due to mistake in translation] so I repost it here

Create a new App Pool that share the same User Credential with the SharePoint site.

Copy the content of your ASP.NET 4.0 web app into a folder under the SharePoint site. In my case it will be C:\inetpub\wwwroot\wss\VirtualDirectories\8080\

Inside IIS Manager convert this folder into a web application.

Go inside C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG and open the Web.config (.NET version here maybe different)

Before anything else right after the <?xml> opening node add the following (in case you dont have configSections defined already, else append to it)

<configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
  </configSections>

After that go to the web.config of the SharePoint site, comment out the exactly same whole secion of <sectionGroup name=”system.web.extensions”> that you
pasted just now. Leave the other sections group untouched

Surround the following nodes with this

<location path="." inheritInChildApplications="false"></location>
<microsoft.sharepoint.client>
<SharePoint>
<system.web>

This will let the child web app to use it’s own settings

Go to the child web app, change the following

<modules runAllManagedModulesForAllRequests="true"/>

TO

 <modules runAllManagedModulesForAllRequests="true">
      <remove name= "SPRequestModule"/>
      <remove name= "PublishingHttpModule"/>
      <remove name= "RSRedirectModule"/>
      <remove name= "StateServiceModule"/>
      <remove name = "SharePoint14Module"/>
      <add name= "Session" type="System.Web.SessionState.SessionStateModule" />
    </modules>

This will disable all SharePoint modules in the child web app and enable back session

After that do IISRest and everything should be working. But if you got error 500 or a blank page please refer to this page on how to debug

Leave a Reply

Your email address will not be published. Required fields are marked *