Custom .NET web application in SharePoint – Error – Cannot create file when that file already exists

Page copy protected against web site content infringement by Copyscape

Recently, I had to troubleshoot a custom .NET web application within SharePoint not loading as it was encountering the following error: ( the web site was deployed to a folder within _layouts)

 

Cannot create file when that file already exists. (Exception from HRESULT:0X800700B7)

 

It turns out the culprit was the entries in the web.config for the custom web application. There was some entries in the web.config that was conflicting with SharePoint web.config and the above error occurred.

Suggestion is to remove configsections and controls and try out. If you still encounter errors, try with minimal entries in the web.config such as customErrors, connection strings, app settings, and assemblies. That should fix the error.