Access denied to Temp ASP.NET directory - asp.net-mvc

Please review my UnauthorizedAccessException ASP.NET error.
Access to the path 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8909a2b1\8566823\Nop.Plugin.Feed.Froogle.dll' is denied.
The error has occured since I changed the website to be hosted through VS 2010 IIS from my machines IIS. My solution has previously worked in VS 2010 IIS as I went from VS IIS to Machine IIS back to VS ISS.
My Problem occurs when I copy dlls to the temp directory.
File.Copy(...
I've tested the various permissions on the directory and nothing helped. i also ran the aspnet_regiis -i command in the hope it would restore the desired permissions on the temp directory.
I dont have any problems if I delete the '../Temporary ASP.NET Directory', it only occurs when I try to replace existing files.
File.Copy("source", "c:\windows\microsoft.net\framework\v4\temporary asp.net files\...\###.dll", true);
Any help would be appreciated. Thanks,

I have just spent hours troubleshooting this very same issue. In my case the dlls were from a solution that was checked in to SourceSafe and when copied into the temp folder they were marked ReadOnly. Once I removed the ReadOnly attribute the problem went away...

You didn't mention which version of IIS you were running on. But you can use FileMon or ProcessMon to determine which user and resource is being denied.

With impersonation involved, this can get tricky. Check your web.config for something like
<identity impersonate="true" ...
The user that is being impersonated also needs permission to the temp folders. I had to reboot, delete the temp folders, and reboot again until it finally took my changes and compiled without this error ...

Related

Why would Visual Studio be trying to copy files from outside the project to the bin and how do I fix it?

I've got a ASP.net MVC project using Telerik/Kendo controls running in Visual Studio 2015. I inherited a project form a coworker who passed it to me through Subversion/Tortoise SVN. When I compile the project on my computer, it give me permission errors about not copying to the bin. I tried changing the read only status and security on the bin folder, but I still get the message. I've never encountered this error before. Any suggestions on how to fix this? Where can I control where these files are being copied to? Maybe I can change it to put it in a file that it does have access to?
Unable to copy file "C:\Program Files (x86)\Progress\Telerik UI for
ASP.NET MVC R3
2017\spreadsheet\binaries\net40\Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.xml"
to
"......\WFC\WFC\WFC\bin\Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.xml".
Access to the path '......\WFC\WFC\WFC\bin' is denied.
1. Clean Project.
2. Open Windows Task Manager and kill vbcsCompiler.exe process.
3. Build Whole Solution. and run.
Note:
Kill vbcscompiler.exe when u see access denied. I think it's bug in vs17.
You are using telerik dlls in your solution, That's why it's pulling in your solution.

How to Fix MVC Cannot create/shadow copy 'XXX' when that file already exists

Several times a day I receive this error while running my MVC 4 Razor project. when i refresh the page it will be solved for only that time. What is the permanent solution of that.
Cannot create/shadow copy 'WebGrease' when that file already exists.
In order to resolve this issue there are two approaches.
Solution 1:
Restart the IIS and Restart the AppPool in which the virtual directory exists.
Solution 2:
You have to tell ASP.NET MVC not to shadow copy the project assemblies to the ASP.NET temporary folders file by updating your web.config with the following entry:
<configuration>
<system.web>
<hostingEnvironment shadowCopyBinAssemblies="false" />
</system.web>
</configuration>
Then restart your application.
Reason:
By default shadow copy is enabled on every appdomain created by ASP.NET MVC. Assemblies loaded will be copied to a shadow copy cache directory, and will be used from there. So that the original file is not locked and can be modified. An error you may encounter when running ASP.Net apps with the debugger is “Cannot create/shadow copy ‘XXX’ when that file already exists”.
here is a work around
https://blogs.msdn.microsoft.com/tom/2008/06/09/cannot-createshadow-copy-file-name-when-that-file-already-exists/
i haven't tried this though!

Antlr3.runtime access denied issue

I'm new to MVC and on my first project, I stuck up in an access denied error.
I have an access denied error when I try to run the MVC application created by previous developer. It is my first day at work and - is kind of not cool. The error said "Antlr3.runtime access denied issue"
Any help will be appreciated.
Your account may not have permission on some directories. If you are working in a windows environment, try giving your account full access to the "Temporary Asp.Net files" which is under c:\windows\Microsoft.NET\Framework.
You need to also check in each version of the Framework folder for that temp asp.net files.
I got the same problem and I deleted the temp folder. After that I executed in admin mode in Powershell the command iisreset and now it works fine.

A very weird problem with localization (ASP.NET MVC)

I'm using Web Developer 2010. I just created a resource file lang.resx with different values in english. Then I created a lang.FR-fr.resx with French equivalents. However after tryingto compile, I get
Error 131 Task could not find "AL.exe" using the SdkToolsPath "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\" or the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A". Make sure the SdkToolsPath is set and the tool exists in the correct processor specific location under the SdkToolsPath and that the Microsoft Windows SDK is installed
This is so weird! If I remove FR-fr part, it will work, but there will be no translation of course.
I went to that directory and found out that I don't have al.exe there. I managed to find it in .NET 2 folder, but after copying it didn't help. It throws an exception. I tried to reinstall .NET 4, to install Windows SDK, and it still doesn't work.
Maybe I can somehow get this al.exe file?
I solved it by restarting the machine :)

How can I install asp.net mvc 2 on IIS7?

I have developed an ASP.NET MVC 2 website, and now need to deploy it to my web server. I've overcome some hurdles already, since ASP.NET was not installed etc. but I've now got to the point where I can serve up plain content files, and if I try to hit one of my MVC URLs I get this:
Could not load file or assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Not surprising, that, as I've not installed MVC2. Problem is, I can't find any good information about how to install it!
The Microsoft Download Center lists 3 files, none of which look promising:
ASP.NET-MVC-2-RTM-Release-Notes.doc
AspNetMVC2_VS2008.exe
mvc2-ms-pl.zip
The site doesn't bother to explain what the files actually are, but I assume that the last file is the source code. That's what it looks like, anyway. The release notes are no help whatsoever, since they're all about installing on your development machine, and indeed the name of the EXE makes it clear that that's all about Visual Studio integration too.
So how do I actually deploy the darn thing?
The other option linked to from Scott Gu's blog is the Microsoft Web Platform Installer. Now, I don't want to install more than just MVC2, and I already have IIS etc. set up, so this seems a bit heavy. But it's all academic, as it refuses to run on my server, saying "your system is not supported" or words to that effect. (The server is Windows Server 2008 Standard SP2, so I really don't know what it's problem is).
Help!
[It's ridiculous that this should be so hard - or perhaps not hard at all, but certainly a well-kept secret!]
To deploy an MVC application, you just need to ensure that you set the references up to copy to your bin folder. Specifically, these DLLs will need to be in there...
System.ComponentModel.DataAnnotations.dll
System.Web.Abstractions.dll
System.Web.Mvc.dll
System.Web.Routing.dll
Note: Copying a reference to your bin folder.
In practice, you do this by following these steps:
Right-click on the reference in
the "references" section of your
project
Select "Properties"
Locate the "Copy Local" property and
set it to "true"
PLEASE NOTE!
System.Web.Abstractions.dll
System.Web.Routing.dll
You only need these two if .NET 3.5 SP1 has not been installed - if you don't have SP1, you will need to include these two dlls, which are part of SP1 and are needed by MVC for routing.
The correct answer is given by Darin Dimitrov in this answer (posted here for your convenience):
You could do a server install which doesn't require Visual Studio installed:
msiexec /i AspNetMVC2.msi /l*v .\mvc.log MVC_SERVER_INSTALL="YES"
Now you are probably asking where's this AspNetMVC2.msi coming from. Actually you download AspNetMVC2_VS2008.exe from here, rename the .exe to .zip and inside you'll find what you are looking for (in the mvcruntime sub-folder).
Copy System.Web.Mvc.dll from your development machine to the application's Bin folder on the web server (or to the GAC).
This file comes from AspNetMVC2_VS2008.exe.
You do not need to put these files in the Server GAC. You can, but you don't need to.
You can simply copy these files to your /bin directory on the server. In fact, if you have Copy Local set to true when you right click on the reference, it will do just that.
You need to make sure the reference path to this file:
System.Web.Mvc.dll
is in your /bin directory.
I find running the web platform installer tool works great for getting servers and development machines running. It can be found here... http://www.microsoft.com/web/default.aspx

Resources