2
votes

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.

3
This just happens to me today..., do you remember what the solution was? - Rosdi Kasim

3 Answers

6
votes

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.

2
votes

Have you tried to add runAllManagedModulesForAllRequests="true" on <modules> in your web.config? I've run into this problem before, and this has always solved it.

As per MVC4 HTTP Error 403.14 - Forbidden

1
votes

It seems an issue realated to permission on hosting. Checking if your folder has network services added as role and also check for iusr Generally for my personal experience is a trouble with role and permission. If you cannot check it ask to your host provider to check role