24 October 2015

Exception trying get context compatibility level: System.IO.FileNotFoundException

Recently I was working on  configuring Forms and Claims based authentication in SharePoint. My aim was to configure both these types of authentication on a single web application.

I tried to achieve this by extending the web-application so that initial web application will support Claims authentication and extended one can will support Forms based authentication. To summarize -

  • Initial web application - Claims based
  • Extended web application - Forms based

After doing this, I deployed some custom SharePoint pages which has code for forms based authentication. When I tried to open the pages, I got following error -

Exception trying get context compatibility level: System.IO.FileNotFoundException: The site https://<extended_web_application>/_layouts/15/<Custom_Folder>/<Custom_Page>.aspx could not be found in the Web application SPWebApplication Name=<initial_web-application>.  
at Microsoft.SharePoint.SPSite.LookupSiteInfo(SPFarm farm" Boolean contextSite Boolean swapSchemeForPathBasedSites Uri& requestUri Boolean& lookupRequiredContext Guid& applicationId Guid& contentDatabaseId Guid& siteId Guid& siteSubscriptionId SPUrlZone& zone String& serverRelativeUrl Boolean& hostHeaderIsSiteName Boolean& appWebRequest String& appHostHeaderRedirectDomain String& appSiteDomainPrefix String& subscriptionName String& appSiteDomainId " Uri& primaryUri)     at Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.GetContextCompatibilityLevel(Uri requestUri)

After a bit of search we realized that SharePoint is trying to find the custom page for forms based authentication under our initial web-application.

To fix this problem, we have to reverse the configuration i.e.
  • Initial web application - Forms based
  • Extended web application - Claims based
After doing this, the custom pages for forms based authentication opened without any error.


No comments: