# Automatic path exclusion does not seem to be working

I have a SharePoint 2013 environment running on Windows Server 2012 with two web applications, each on a separate web site. As far I as know, it's current with updates.

The server shares the sites with a non-SharePoint ASP.NET application (ASP.NET MVC 4.0 under .NET 4.5). It appears to be properly excluded from SharePoint as it should be - I can navigate to it, use it, etc.

Today I deployed a second ASP.NET application (also an ASP.NET MVC 4.0 application under .NET 4.5) through a file copy to the server. I created a virtual directory in IIS pointing at the folder, and I marked it as an application.

However, I can't seem to get it to work as expected. SharePoint seems to have to be involved, and it's unhappy, so I'm broken either way. Details:

• If I put the application into the same application pool at the SharePoint site, I can get to a text file in the application, but for ASP.NET code I get Dynamic operations can only be performed in homogenous AppDomain. I found some references to changing settings in web.config or machine.config but the setting in question isn't present on the server.

• If I put it into its own application pool set (in Integrated mode; the other application is working with its own app pool in Integrated mode), I get a simple 500 error. Nothing shows in the ULS log or the Event Log. Failed Request Tracing simply indicates the 500 - there's nothing else in the XML file except the 500 error result (no real tracing in other words).

• If I put it into its own application pool set for 'Classic' mode, I get:

The web.config is very simple:

<?xml version="1.0" encoding="utf-8"?>
<!--
-->
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
</connectionStrings>
<appSettings>
</appSettings>
<system.web>
<compilation targetFramework="4.5">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" />
<authentication mode="None" />
<pages>
<namespaces>
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>


I'm not sure where to even look at this point to move forward with this. Ideas?

I kept coming across this question while researching this same problem in my SP2013 deployment. Thought I'd add the answer in case anyone else has this problem.

Sharepoint does indeed exclude managed paths by default. However, if you create a VD or Application under the the main SP web site, it's going to inherit web.config values regardless of if it's included as a managed path. Obviously, you need these config values if you want SP to handle things for you, but we want to remove these.

Add/modify the web.config in the virtual directory/application with the following:

<system.webServer>
...
<remove name="FederatedAuthentication" />
<remove name="SessionAuthentication" />
<remove name="SPApplicationAuthentication" />
<remove name="SPWindowsClaimsAuthentication" />
...
</system.webServer>


This gets some of the SP handlers out the way and it won't get in the way of your application.

I have spent a long time trying to get my ASP.net winforms and MVC 5 Apps to sit along side of Sharepoint 2013 using their own application pool. I though this answer will help others with resolving this issue.

My end goal is to have 3 or more application running on the 1 web server hosted on port 80 using.

• Sharepoint 2013
• MVC5App
• WinFormsApp

This is how I resolved it. The end result will provide the following URL's

 - http://intranet/
- http://intranet/Apps/MVC5App
- http://intranet/Apps/WinFormsApp


Create a new application pool "MyAppsAppPool" that targets .net framework 4.0 and pipeline mode is integrated. Note: this is optional but I find it better to run my application in its own pool so it does not interfere with Sharepoint.

Create a folder C:\inetpub\wwwroot\Apps which will be used as a base for all your asp.net applications.

Add the following web.config file to the Apps folder.

<?xml version="1.0"?>
<configuration>
<system.web>
<!-- Turn off all custom error message. This is useful in identifying what is going wrong.
Note: use mode="RemoteOnly" if you just want to view error message on localhost.
-->
<customErrors mode="Off" />
<!-- Enable Session State for pages which is disabled by Sharepoint 2013
This will resolve the "Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive" message. -->
<pages enableSessionState="true" />
<!-- Disable legacyCasModel used by Sharepoint 2013.
This will resolve the "Dynamic operations can only be performed in homogenous AppDomain" message. -->
<trust legacyCasModel="false" level="Full" />
</system.web>
<system.webServer>
<modules>
<!-- Remove All Modules used by Sharepoint 2013 -->
<remove name="SPNativeRequestModule"/>
<remove name="ScriptModule"/>
<remove name="DesignHttpModule" />
<remove name="SPRequestModule"/>
<remove name="PublishingHttpModule"/>
<remove name="StateServiceModule"/>
<remove name="SharePoint14Module"/>
<remove name="FederatedAuthentication"/>
<remove name="SessionAuthentication"/>
<remove name="SPWindowsClaimsAuthentication"/>
<remove name="SPApplicationAuthentication"/>
<!-- Re Enable sessions which are remove by Sharepoint 2013 -->
</modules>
</system.webServer>
</configuration>


Using IIS add an application to the Sharepoint Site using the following values

Alias: Apps
Application Pool: MyAppsAppPool
Physical Path: C:\inetpub\wwwroot\Apps


At this stage you should be able to serve a simple index.html file from the Apps folder. Always good to test your progress.

Now you can copy your MVC5App and WinFormsApp to the Apps folder and convert them to Applications which use the MyAppsAppPool.

As web.config file are inherited I find this method useful as I can easily create new virtual applications under the Apps folder without having to modify the web.config files for MVCApp and WinFormsApp.

I can easily copy any .net framework application to the Apps folder without having to worry about disabling sharepoint modules or enabling features that Sharepoint disabled.

Some useful resources that helped me with this issue but seemed to target Sharepoint 2010 are as follows. But note I did not need to go into the full extent which these articles suggest. I only need to perform the steps as listed above. I did not want to modify web.config for sharepoint and .net.

I didn't have enough rep to post more than two links. So reference links are provided in the comments.