.net – 403 – Forbidden: Access is denied after successful web deployment

asp.netiismsdeploynetweb-deployment

I deploy MVC 5 application to IIS running on Windows 2012 R2 with WebDeploy 3. Everything is fine except sometimes after successful deployment I get 403 – Forbidden: Access is denied error when accessing the site from a browser. Recycling the pool fixes the issue but it's not suitable option. I expect IIS to automatically recycle the pool once WebDeploy finishes updating the files

..........
Info: Updating file (blabla\Web.config).
Info: Adding ACL's for path (blabla.com)
Info: Adding ACL's for path (blabla.com)
Total changes: 22 (0 added, 0 deleted, 22 updated, 0 parameters changed, 1314018 bytes copied)

Why? How do I troubleshoot the issue?

There are no warnings or errors in Windows Event log (Application, Security, WebDeploy or IIS). The site uses InProc session, targets .NET 4.5, the app pool has default settings (runs under ApplicationPoolIdentity). IIS authentication enables anonymous and forms modules only.

Best Answer

This just happened to me today... spent several hours scratching my head trying various solutions offered on SO.

I am using Visual Studio 2017 Community... and I am deploying to Windows Server 2012 R2 and also to Windows Server 2016.

The only solution that works for me is to uncheck the Precompile during publishing setting.

Uncheck precompile during publishing

Why this makes the difference is beyond me.

Related Topic