Error: It is an error to use a section registered as allowDefinition= ‘MachineToApplication’ beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

There can be different reasons why this happens, however what I needed to do to fix this was:

Check for and remove any nested web.config files with authentications and full settings in.