ASPNET user does not have write access to Temporary ASP.NET Files - asp.net

I get the following error when running my Visual Studio 2008 ASP.NET project (start without Debugging) on my XP Professional box:
System.Web.HttpException: The current identity (machinename\ASPNET) does not have write access to 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files'.
How can I resolve this?

Have you tried, the aspnet_regiis exe in the framework folder?

I had the same problem. This is what I did:
Go to c:\windows\microsoft.net\framework\v2.0.50727
right click on "Temporary ASP.NET files"
Security tab
Select "Users(xxxxxx\Users) from Group
check "Write"
OK

Either grant that user the level of access to that directory, or change the identity that the application's application pool runs under - in IIS Manager, determine what App Pool is used to run your application, then in the App Pool section of IIS Manager, look at the properties for that pool - the tab you want is "Identity" I think (this is off the top of my head).
You can set it to another user account - for example, Crystal Reports .Net requires update and delete access to C:\Temp - so we have a "webmaster" user, with administrator access, and use that identity for those applications.

You can try to fix it using the automated regiis utility aspnet_regiis.ext available in c:\windows\microsoft.net\framework\v2.0.50727
Otherwise just manually add the needed file permissions as noted in the error.

you can right click the Visual Studio & select run as administrator.

I had this problem when trying to build a Web Deployment Project (*.wdploy).
Simply creating the folder on the framework path solved the error.

Just because the most recent answer is 5 years old, what had to be done in our environment was to delete the app, app pool and recreate them.
We evidently have some security under the hood with recent changes to it.
Doing this re-created a folder in Temporary ASP Net Files with all the correct permissions. Why the one site I happened to just get from source control, rebuild, etc. failed this way, no idea. 2 others recently set up where Get Latest Version was downloaded, rebuilt, etc. they just worked.
But ripping out the app, app pool and just recreating them with the same IIS permissions as the 2 other known working sites recreated all the needed objects and now it all works.

Make sure the ASPNET user has permission to write to that folder. Right click on the folder, Properties, Security tab.

Related

You do not have permission to access the IIS configuration file - Web app error

I am trying to load existing c# web applications and getting below errors while loading any web project:
Creation of the virtual directory http://localhost:/ failed with the
error: You do not have permission to access the IIS configuration
file. Opening and creating web sites on IIS requires running Visual
Studio under an Administrator account.. You will need to manually
create this virtual directory in IIS before you can open this
project.
The following error occurred when trying to configure IIS Express for
project xxx.WebApi. You do not have permission to access the IIS
configuration file. Opening and creating web sites on IIS requires
running Visual Studio under an Administrator account.
I tried following, but in vain:
Running VS 2017 pro as an administrator.
I ensured that I have access to %systemroot%\System32\inetsrv\ and C:\Windows\System32\inetsrv\Config folders.
I have installed all IIS compatibility windows features through control panel.
Restarted IIS manager.
Created virtual directories.
Changed registry path of HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal from u:\ to C:\Users\MyUser\Documents.
Uninstalled IIS Express 10.0 from control panel and reinstalled it through VS2017 installer by clicking – Individual components – cloud, database server – IIS Express.
Repaired VS 2017.
Got admin access on machine.
Created new empty web project but getting same error while new console app runs without errors.
Restarted machine after every installation related change.
All the solutions tried are mentioned on stackoverflow but are not working for me. Is there something trivial that I am missing? Please guide me to crack these IIS errors.
I was able to solve this issue doing the following:
1- Go to C:\Windows\System32\inetsrv and double click on directory config and accept the warning message.
2- Go to C:\Windows\System32\inetsrv\config directory and double click on directory Export and accept the warning message.
Then you will be able to run the app in your local IIS without being an administrator. You can follow the path in the given Image.
This solved the problem for me with Visual Studio 2017, .Net Core 2.2 and IIS Express 10.
You need to ensure devenv.exe has sufficient permissions. You can find it at:
C:\Program Files OR Program Files (x86)\Microsoft Visual Studio nn.n\Common7\IDE
Right click on the exe, select Properties, Security. I gave Administrators full control as I'm running VS under admin.
My Simple solution was to right click on Visual Studio and click Run as Administrator. But a solution above tells you how to have Visual Studio always run without having to run as an administrator.
All these solutions could not work for me. The issue was, I have accidently uninstall IIS from control panel even it was install and showing me. but was removed from control panel. I reinstall IIS latest version and able to fixed the problem. This might help for others.
This link help me
VS2017 RC - The following error occurred when trying to configure IIS Express
The issue for me was caused when I modified my project to override application root URL. After a push/merge and new branch my project would not load any longer. reverted the changes and all is well again.
Open an elevated command prompt and enter the following command to substitute a drive path for U drive.
c:\windows:\system32> Subst u: C:\Users\MyUser\Documents
I had replaced ‘U:’ path in registry with ‘C:\Users\MyUser\Documents’ previously. I think that was not sufficient. Some references of u:\ might have been hindering IIS.
The total substitute command must have replaced all references and the IIS config error got resolved. Hopefully, now I’ll be able to load my web apps.
I had the same issue, but instead of the workarounds (such as first double-clicking certain directories each time or running the security risk of always having to always run my VS as administrator), was able to permanently resolve the issue by deleting the "ProjectName.csproj.user" file and that fixed it. I guess there was some incompatible setting in the user file that VS couldn't deal with.
For older versions, change the option from IIS to your solution name, before clicking on the green play like run button, to build and run the application.
We resolved this by removing the project and adding it back.
If you're used to run your Visual Studio via shortcut with 'Run as administrator' checkbox marked, double check it is indeed still selected. For some reason mine had unchecked itself resulting in inability to load an IIS project. I was 100% sure my VS had these administrative privileges as usual, which made me try all the Internet proposed solutions except for the most obvious one.
Restarting Visual Studio worked for me.

IIS7 MVC Routing Not Working

Our company ships an MVC based product (targeting v4.5) which has stopped working on a customer site for what appear to be environmental issues - a build which worked with no problems once upon a time now gives a 403.14 - The Web server is configured to not list the contents of this directory.
.
What I think is happening...
The user accesses http://server/AppName
Because it's an MVC app, the default route (Reports/Index) should be used.
Instead IIS is looking for a default document...
... and, not finding one, it assumes the user wants to list the contents of the directory...
...which is not enabled so it throws a 403.14.
.
What I've tried so far...
Accessing the route directly.. results in 404 error. So I'm pretty
sure IIS doesn't realise it should use routing.
Use aspnet_regiis to register ASP.Net with IIS. This was done from the Framework64 folder since...
OS is 64 bit - Windows Server 2008 (Standard without Hyper-V)
IIS is 64 bit - though Enable 32-Bit Applications is true
Checked AppPool is targeting v4 of the framework - it is.
Changed AppPool mode to Classic - was pretty sure it should be integrated but was worth ruling it out. It is now back to Integrated
Confirmed RunAllManagedModulesForAllRequests is set to true in the web.config.
Checked permission conditions defined in <system.webServer> section of web.config are met - they are.
Created the simplest of MVC applications and deployed it - same problem.
Running the command shell as Administrator unregistered ASP.Net using aspnet_regiis -ua and re-registered using aspnet_regiis -enable -i. We hit a couple of permission problems - and the Temporary ASP.NET Files directory was missing but once they were address we were back to the same error.
Added a simple default.htm - when present, this is served in response to the http://server/AppName request.
I'm clean out of ideas and all google hits suggest some combination of the above - or enabling directory browsing (which I think is just a symptom rather than the root cause).
Also, not sure if it's relevant but the amount of configurable elements available for the application in IIS seems a bit below what I would have expected...
Have you Checked the user the application pool process is running under? I think Your site needs to run with permissions to execute the .net libraries and I've seen this just change for seemingly no reason (probably related to an overzealous update to the system).
You can try with the Enabling directory browsing .
assuming you are under Windows Server 2012 or Windows Server 2012 R2
On the taskbar, click Server Manager.
In Server Manager, click the Manage menu, and then click Add Roles
and Features.
In the Add Roles and Features wizard, click Next. Select the
installation type and click Next. Select the destination server and
click Next.
On the Server Roles page, expand Web Server (IIS), expand Web
Server, expand Common HTTP Features, and then select Directory
Browsing. Click Next.
On the Select features page, click Next. On the Confirm installation
selections page, click Install. On the Results page, click Close.
if you using the Windows PC try this in your command prompt as follows:
go to C:\Program Files\IIS Express
then press Enter:appcmd set config
/section:system.webServer/directoryBrowse /enabled
Maybe this is your case https://forums.iis.net/t/1157304.aspx
SQL Server Reporting Services creates a folder called Reports by
default if you install it on IIS. If you install SQL 2008 then
Reporting Services doesn't need to use IIS and instead will try to
reserve the URL with the HTTP.Sys service.
I believe this is the cause of the conflict you are seeing. What you
could try is changing the URL that Reporting Services uses via the SQL
Server Configuration Wizard.
Also I found that
Report Manager of SQL Server can use reports path http://<server name>/reports
Configure a Native Mode Report Server for Local Administration (SSRS)
I think the problem is IIS features that are not installed yet. I have met this kind of problem frequently in Windows Pro. Make sure to turn on every feature under Internet Information Service -> World Wide Services because by default IIS is configured to use WebForms. So there might be some features that not installed yet to use MVC, especially ISAPI filters. In my case, that was the solution. I hope it helps.
Something similar i encountered using VS 2017 & ASP.NET MVC.
Was working on the project for long with no problems at all but suddenly the routing started misbehaving & stopped working.
So I changed the Port in Project Properties Page & it started working.
I really don't know what is the relation between a port & MVC routing modules. Someone else can enlighten if at all this helps.
I had the same problem and I just created an application pool out of the Default Web Site in IIS and stoped the default web site. With that difference you will not have the application pool's path
I know it's been a long time since this question but i've had the same problema recently. I've tried every single configuration, just like #amcdermott did, but the only action that solve the problem was reinstalling .NET Framework.
My app was built under .NET Framework 4.5.2. The application server had the version 4.6.1 and 4.5.2 installed. So, i uninstalled all framework versions and installed the one that i needed.
Please, make sure that no other applications use superior versions of .NET Framework if you going to try this solution.
Here are some quote I find on Microsoft official site which I think may help:
For site administrators
This problem occurs because the Web site does not have the Directory Browsing feature enabled, and the default document is not configured. To resolve this problem, use one of the following methods:
Method 1: Enable the Directory Browsing feature in IIS (Recommended)
To resolve this problem, follow these steps:
Start IIS Manager. To do this, click Start, click Run, type inetmgr.exe, and then click OK.
In IIS Manager, expand server name, expand Web sites, and then click the website that you want to modify.
In the Features view, double-click Directory Browsing.
In the Actions pane, click Enable.
Method 2: Add a default document
To resolve this problem, follow these steps:
Start IIS Manager. To do this, click Start, click Run, type inetmgr.exe, and then click OK.
In IIS Manager, expand server name, expand Web sites, and then click the website that you want to modify.
In the Features view, double-click Default Document.
In the Actions pane, click Enable.
In the File Name box, type the name of the default document, and then click OK.
Method 3: Enable the Directory Browsing feature in IIS Express
Note This method is for the web developers who experience the issue when they use IIS Express.
To do this, follow these steps:
Open a command prompt, and then go to the IIS Express folder on your computer. For example, go to the following folder in a command prompt:
C:\Program Files\IIS Express
Type the following command, and then press Enter:
appcmd set config /section:directoryBrowse /enabled:true

Unable to access the IIS metabase

An ASP.NET web project loads with up the solution, but I get this error
The Web Application Project is configured to use IIS. Unable to access the IIS metabase. You do not have sufficient privilege to access IIS web sites on your machine.
How can this be solved?
This may have nothing to do with registering ASP/IIS. The reason is exactly what the error message says: Visual Studio devenv.exe is not running with sufficient privileges to access the IIS process, and it needs to do this if your solution contains a web project whose Web settings say to use IIS rather than the VS dev server.
There are two solutions to your problem:
Run VS as an Administrator and reopen the solution/project.
Edit the web application's project file with a text editor and change this line
from True to False:
<UseIIS>True</UseIIS>
That will stop it using IIS and demanding higher privileges.
The reason VS demands Admin privileges is, I believe, because it will try and create the IIS web site for you on demand if it doesn't exist.
An answer that worked for me can be found here:
https://stackoverflow.com/a/17460774/3005965
Basically, go to %systemroot%/inetsrv/config. When prompt appears saying you need admin privileges, click Continue.
This should clear up your issue.
Just try to access Visual studio as Admin right click and choose run as administrator.
may fixes this problem.
and take a look at this link for instructions on creating a shortcut.
I ran into this problem when I had copied a project to a new project. I opened the project file (.csproj) and removed the value from the IISUrl element:
from: <IISUrl>http://localhost:21222</IISUrl>
to: <IISUrl></IISUrl>
Have you registered the .NET framework with IIS? You need to run the aspnet_regiis.exe utility found at %WindowsDir%\Microsoft.NET\Framework\vx.y.zzzz\. Run it as administrator as follows:
aspnet_regiis.exe -i
-i : Installs the version of ASP.NET that is associated with Aspnet_regiis.exe and updates the script maps at the IIS metabase root and below. Only the script maps for applications that use an earlier version of ASP.NET are updated. Applications that use a later version are not affected.
Find out more about the utitlity here.
This error also occurs if you modified your Machine.config and added some "invalid lines":
For example, I added some appSettings, to the configuration section (which IIS didn't like).
Just register your Web-project in your local IIS. All the settings you will find in *.csproj file. That works for me.
first uncheck internet information service from turn windows features on or off.
then uninstall iis from your system and restart it. after restarting it install iis again from https://www.microsoft.com/en-us/download/confirmation.aspx?id=34679 and try to open again.
Step 1: Close Visual Studio
Step 2: Go to Project Folder and find ".vs" folder Note: It may be hidden
Step 3: Delete ".vs" folder
Step 4: Open Project Again

AnkhSVN breaks ASP.NET sharing permissions with SVN 1.7

The Background (skip to the bottom if you want the question)
Recently I upgraded an SVN repository (hosted on assembla) to SVN 1.7. After doing so, we started to intermittently encounter lots of File Access Denied errors on the ASP.NET site pages that sit in the local working copy of the repository.
Some folders also started to get weird file permissions (they became marked read-only) and user sharing got removed from them. These problems would only start occurring after an update/commit cycle, via AnkhSVN's Visual Studio plugin, but not all the time; it seemed highly temperamental.
The only temp-fix we've found so far is to commit any outstanding changes, delete the local copy and re-checkout a full working copy (with TortoiseSVN). However, that is not a viable fix, and it is seriously impacting on productivity.
This site is an Azure based ASP.NET WebWorkerRole. It has never given problems before the upgrade to SVN 1.7. I tried fiddling with the internal IIS permissions to get around the problem, however, no dice.
My Environment
Visual Studio 2010 Ultimate 10.0.40219.1 SP1
AnkhSVN 2.3.10509 (latest version, supports SVN 1.7.1)
TortoiseSVN 1.7.1, Build 22161 - 64 Bit
Running in Debug Mode via the Azure emulator environment
The Question
Is it possible for SVN 1.7 or any of the tools in my environment to break file permissions so that the files become unusable in an ASP.NET site? and more importantly, how do I fix this?
The exact file permission error dumped out is this:
Access to the path '//file//' is denied.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessException: Access to the
path '//file//' is denied.
ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request
identity. ASP.NET has a base process identity (typically
{MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and
the configured application pool identity on IIS 7.5) that is used if
the application is not impersonating. If the application is
impersonating via , the identity will be
the anonymous user (typically IUSR_MACHINENAME) or the authenticated
request user.
To grant ASP.NET access to a file, right-click the file in Explorer,
choose "Properties" and select the Security tab. Click "Add" to add
the appropriate user or group. Highlight the ASP.NET account, and
check the boxes for the desired access.
But a clean working copy will not generate this error. Comparing the permissions of the two, it seems the working copies that are not bugged are shared (with IUSR and the local account), whereas the broken ones have zero sharing, yet the sharing is never changed by the user.
When subversion updates a file it first creates a temporary version in .svn/tmp/. It then moves the file into the right location. (This to avoid corruptions)
In 1.6 it did this for every directory by itself, but in 1.7 there is just a .svn in the top level directory of your working copy.
If somehow the filesystem permissions of this .svn directory are restricted, it is possible that the restrictions are copied with the file when it is moved in place.
(Subversion doesn't change the permissions itself on Windows)
I solved this by accessing the security settings for the website folder and and clicking Advanced and then Change Permissions for the IIS_IUSRS user. I checked the "Replace all child object permissions with inheritable permissions from this object" and clicked apply.
Before that, I had given the IIS user full permissions to the hidden tmp folder in the root of the checkout, but I don't know if this helps with anything.
I'm not sure if this is a permanent fix, but in case it is not, you can at least use it to reapply permissions for all the files in a single operation.
Much information is located in .svn folders inside directory where project was checked out. So in my opinion better use SVN separately from advanced integration tools. Also this deals with solving problem like this.
I found this exact same issue happened when I did a 'Revert' using:
Tortoise Svn 1.6.16
AnkhSVN 2.3.11269.1348.
Visual Studio 2010 Professional
Windows 7 - 64 bit.
I was completely puzzled the first time I encountered the permissions error and started off by thinking it was my code. After a while of fiddling about I ended up deleting the whole project and re-downloading from Subversion which fixed the issue.
When this problem happened again I looked more closely at the reverted file, and I found the permissions on the reverted files do not match the permissions of the other files. Specifically 'Users' permissions, for the machine that Visual Studio is running on, is missing altogether.
So I just added it in by:
Right clicking on the problem file. This caused the file properties window to appear.
Then clicked on 'Edit...'. The permission window appears.
Then clicked on Add and the 'Select Users, Computers, Service Accounts, or Groups window appears.
Click on the Object Types button and check all the boxes.
Click on the Locations button and make sure your machine name is selected.
Type in 'users' then click the 'check names' button.
Click OK on all the windows to close them.
Your website should now run without the permissions error.

IIS 6.0 and ASP.NET - Could not write to output file ... The directory name is invalid

I'm running IIS 6.0 on Windows 2003 and started getting this error:
Compiler Error Message: CS0016: Could not write to output file 'c:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\7382c13f\ea9b3ff7\App_global.asax.zodyof_q.dll' -- 'The directory name is invalid. '
I've checked all the permissions, and everything is as it needs to be - plus, the error message doesn't mention permissions. I've tried the following already:
Following the instructions from this [outdated] KB article: http://support.microsoft.com/kb/825791/en-us
Repairing the .NET Framework v3.5 installation, then rebooting
Deleting the contents of c:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root, then running iisreset
Resetting the permissions on c:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root, then running iisreset
Resetting the permissions on c:\WINDOWS\TEMP, then running iisreset.
Any suggestions?
Other notes/responses:
The Indexing service is disabled.
I've found an answer that is applicable if you've installed ANTS profiler and it crashed while profiling. This KB Article describes one of the solutions:
http://www.red-gate.com/supportcenter/Content.aspx?p=ANTS%20Profiler&c=knowledgebase\ANTS_Profiler\KB200903000362.htm
Create a temporary folder under %SystemRoot%, and then name it Temp.
Grant full permissions on the Temp folder to the aspnet user account in .NET Framework 1.0 or to the NETWORK SERVICE user account in .NET Framework 1.1.
Right-click My Computer, and then click Properties.
On the Advanced tab, click Environment Variables.
Select the TEMP variable under System variables, and then click Edit.
Type %SystemRoot%\TEMP in the Variable Value box, and then click OK.
Repeat steps 5 and 6 to edit the TMP variable. Click OK two times.
Click Start, and then click Run.
To reset Internet Information Services (IIS), type iisreset on the command prompt.
Use SysInternals FileMon (or ProcMon if you like) to see the real file it is bitching about. You can restrict it to just monitoring IIS if you have a busy server, although I'd start with all processes and just capture a couple of seconds of output.
Before running, ensure IIS has been reset using iisreset /restart so that the error is not cached from before.
Ryan
To every body who still has the problem!
Mine is solved by the followings
http://support.microsoft.com/kb/825791
I had the same error running IIS 7.0 / Vista Ultimate / .NET 2.0 Web App. I tried setting "Full Control" permissions on temporary folder for NETWORK SERVICE user (right-click on folder c:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727, Properties, Security tab) and turning off antivirus and UAC, but it didn't help.
But this worked as magic: Open IIS Manager -> Select "View Application Pools" from right menu -> Select "Advanced Settings" -> Set your username (and password) in "Identity" property -> Restart IIS
If this doesn't work, check additionally that you're an owner of c:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727 folder (right-click, Properties, Security tab, Advanced, Owner tab)
OK, when you repaired the installation do you mean ASPNET_REGIIS -u / ASPNET_REGIIS -i ? that would fix disk permissions.
It might be your virusscanner; exclude your .net temporary folders / inetpub if you can and if its safe.
Have to tried disabling windows Indexing Service for the temporary asp.net files folder
I received the same error. The anti-virus/security software (McAffee Viruscan Enterprise) was preventing visual studio tool csc.exe to dynamically compile code and create the entity data model dll in the directory folder above which falls under the windows directory folder. There is a section in McAffee called access protection that has a rule called Maximum Protection that prohibits creating executable files in the windows directory folder. Simply temporary disable the rule or access protection to compile the website successfully.
Here is the final solution :)
First give all the permission to ASPNET account , NETWORK SERVICE account to "ASP.NET Temporary files" folder under whichever the framework it is using.
like C:\windows\microsoft.net\framework\v2.xxx\ASP.NET Temporary files.
Check the temporary folder configured for your machine under environment variables for TEMP and TEMP.
For that folder also give all the permission to ASPNET account , NETWORK SERVICE accout. Reset the IIS
It should be working fine.
From windows server 2003 x64 , IIS6 , net 4.0 , asp application I was presented with the error:
Compiler Error Message: CS0016: Could not write to output file 'c:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\7382c13f\ea9b3ff7\App_global.asax.zodyof_q.dll' -- 'The directory name is invalid. '
It was resolved when I created the DIR
d:\temp
No idea why D:\temp was important but I will update this answer with a reason as soon as I know.
Permissions on the DIR were:
admin full
creator owner special
system full
users read&execute / list / read
No IIS specific user permission was defined.
Working to migrate to IIS7 host but thought this answer maybe helpful for someone.

Resources