1

I've created a new WebApi prject from a blank WebApi template, added a controller with a post, but whenever I try to run the project, I get the following error:

Exception thrown: 'System.UnauthorizedAccessException' in mscorlib.dll

Additional information: Access to the path 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\~AspAccessCheck_90a342644584.tmp' is denied.

I can't find anything by searching other than permissions etc, but I've not changed any permissions and it hasn't even got to running my code yet. I've tried setting permissions in this folder to everyone, but the error still occurs.

EDIT: It turns out the above is caused by JustMyCode setting being disabled. Enabling it made the error go away.

I tried to find an explanation, but only came across a question that exhibits a similar problem (Admob WP8 System.UnauthorizedAccessException).

So why does just my code throw an UnauthorizedAccessException in mscorlib.dll when it is disabled?

Community
  • 1
  • 1
Mr Shoubs
  • 14,629
  • 17
  • 68
  • 107
  • Possible duplicate of [Access to the path "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\cbnonreg\fc933fca\bbf91eea" is denied](http://stackoverflow.com/questions/391767/access-to-the-path-c-windows-microsoft-net-framework-v1-1-4322-temporary-asp-n) – Igor Jul 13 '16 at 21:17
  • Are you running Visual Studio as Administrator? – Petre T Jul 13 '16 at 22:10
  • @PetreTurcu, I am in the local admin and domain admin groups, I've also tried to run VS in "run as administrator" mode. – Mr Shoubs Jul 14 '16 at 08:53

1 Answers1

0

If you debug with IIS Express you can see that it tries to write a file to test access. So you need to grant write permission to a current user to write to that folder.

Andrii
  • 1,081
  • 1
  • 11
  • 24