Hitting 401 – Unauthorized for FBA enabled sites in SharePoint

Among the multitude of issues I faced in the process of creating an internet facing publishing portal in SharePoint, this one was killing me for a couple of days.

After extending my web application to intranet zone, i enabled FBA authentication with anonymous access in my default zone. The strange thing i noticed is that if you open a page for the first time, you’ll hit a page showing 401 – Unauthorized error. But if you refresh the page in your browser, the page loads fine in anonymous mode. Each and every ‘postbacks’ in your pages will face the same issue. After hours of googling and found the solution for the problem. To get rid of the issue

1. Change <compilation batch=”true” debug=”true”> to <compilation batch=”false” debug=”false”> in your web.config.

2. Allow anonymous access in the windows authentication zone. To do that follow these steps.

  • Go to Central Administration -> Application Management -> Authentication Providers
  • Select your web application
  • Choose the appropriate zone which is configured to use windows authentication
  • Check ‘Allow anonymous access’
  • Click OK

Whoomp! The issue is gone.