permission to change web.config in window azure - asp.net

I deploy my application in azure successfully.In some case I have write some thing in my web.config file.But when I try to write in web.config I got permission problem.In local I have not any problem after give read/write permission to IIS User.
I search but unable to find any thing about read/write permission in azure.
Is there any way to give permission to read/write in web.config file.Or I am totally in wrong way.Thanks .

You're doing it wrong. Don't change the web.config file from inside the role because all the changes will be lost once the role or any of its instances is redeployed (which can happen for a number of reasons including a VM crash and later automatic recovery initiated by Azure platform).

Related

Cannot read configuration file due to insufficient permissions on web.config [duplicate]

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Error Code : 0x80070005
Config Error : Cannot read configuration file due to insufficient
permissions
When add new web application in IIS 7.5 and run it, this page shown to me, how to solve this problem win7 ultimate visual studio 2010
The message is clear.
Cannot read configuration file due to insufficient permissions
How to solve it.
Every asp.net application is run under one pool assigned to it, and each pool is run under a specific account.
Open the IIS, locate the pool under which your app is try to run, see the user that is assigned to that pool, and give read permissions to that user on your full site directory tree.
Especial for the web.config
The web.config, its the configuration file that message says, must have (and) write permissions.
So you locate web.config on the root of your site, right click on it, go to permissions and give on the pool-user, the write capability. The pool user, is the user under the witch the pool is run, as I explain below.
More details
To been able to run a public asp.net site with IIS, each file on the directory must have permissions for two accounts.
One account that is permitted for public access, and the account that assigned to that application pool have.
To find/assing the first account you go to your iis site | Authentication | Edit, and see or change it as you see on that screen shot.
Now note that name and we going to find the user under with the pool run.
Go the your IIS Site and click on the Basic Settings to find the pool name, then go to the IIS | Application Pools and see the Identity column, and note the name of the user under the witch your site is run.
Now that we have the two users names we go to the root of the site and set the minimum of permissions that is the read as
Some Notes
If the IIS_Public_ACCESS_USER is not give read permission the site is run, but ask for password
On some directories you need and write permissions, if you let for example your users upload images, or keep on App_Data, some database files. Only for that directories you give and the write permissions to the IIS_POOL_USER.
Some directories, like the App_Data and App_Code have direct protection from asp.net and they not allow anyone from the client side to run or view whats is in there.
On the public directory that allow write access to your user add one web.config and totally disable all the running of asp.net files.
More to read for the directories that give write permissions I've been hacked. Evil aspx file uploaded called AspxSpy. They're still trying. Help me trap them‼
It looks like your IIS_User doesn't have the necesarry permissions to access your website in C:\Users....\Visual Studio 2012\Websites...
Also make sure your application is running the correct .NET version (2.0, 4.0, ...)

How to set correct file permissions for ASP.NET on IIS

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Error Code : 0x80070005
Config Error : Cannot read configuration file due to insufficient
permissions
When add new web application in IIS 7.5 and run it, this page shown to me, how to solve this problem win7 ultimate visual studio 2010
The message is clear.
Cannot read configuration file due to insufficient permissions
How to solve it.
Every asp.net application is run under one pool assigned to it, and each pool is run under a specific account.
Open the IIS, locate the pool under which your app is try to run, see the user that is assigned to that pool, and give read permissions to that user on your full site directory tree.
Especial for the web.config
The web.config, its the configuration file that message says, must have (and) write permissions.
So you locate web.config on the root of your site, right click on it, go to permissions and give on the pool-user, the write capability. The pool user, is the user under the witch the pool is run, as I explain below.
More details
To been able to run a public asp.net site with IIS, each file on the directory must have permissions for two accounts.
One account that is permitted for public access, and the account that assigned to that application pool have.
To find/assing the first account you go to your iis site | Authentication | Edit, and see or change it as you see on that screen shot.
Now note that name and we going to find the user under with the pool run.
Go the your IIS Site and click on the Basic Settings to find the pool name, then go to the IIS | Application Pools and see the Identity column, and note the name of the user under the witch your site is run.
Now that we have the two users names we go to the root of the site and set the minimum of permissions that is the read as
Some Notes
If the IIS_Public_ACCESS_USER is not give read permission the site is run, but ask for password
On some directories you need and write permissions, if you let for example your users upload images, or keep on App_Data, some database files. Only for that directories you give and the write permissions to the IIS_POOL_USER.
Some directories, like the App_Data and App_Code have direct protection from asp.net and they not allow anyone from the client side to run or view whats is in there.
On the public directory that allow write access to your user add one web.config and totally disable all the running of asp.net files.
More to read for the directories that give write permissions I've been hacked. Evil aspx file uploaded called AspxSpy. They're still trying. Help me trap them‼
It looks like your IIS_User doesn't have the necesarry permissions to access your website in C:\Users....\Visual Studio 2012\Websites...
Also make sure your application is running the correct .NET version (2.0, 4.0, ...)

Web.Config - Cannot read configuration file due to insufficient permissions

I am getting the error:
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x80070005
Config Error Cannot read configuration file due to insufficient permissions
Config File \\?\C:\inetpub\wwwroot\web.config
The file itself has full permissions for IUSR. IIS is running its app pool under ApplicationPoolIdentity. I did a file monitor on the file, and I see this:
9:04:43.8035456 AM w3wp.exe 8104 CreateFile C:\inetpub\wwwroot\Web.config ACCESS DENIED Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, AllocationSize: n/a
No idea why I am getting this error... Any ideas?
Try giving read/write access to these accounts to the root folder of your Web application and all files/subs within:
NETWORK, NETWORK SERVICE, and of course IIS_IUSRS
I found that adding the mymachine/USERS with full permissions to C:\inetpub\wwwroot fixed the issue.
The problem was caused because I shared some sites content inside C:\inetpub\wwwroot with other developers. This must have changed permissions and broke my IIS completely.
First, make sure IUSR has Read permission on the config file (which I believe you have done that)
Then, change IIS authentication method to BasicAuthentication
If still not working, probably the .config extension is not properly installed in IIS.
Try all 3! Good luck!
EDIT: Forget to ask you, what kind of appliation is it?
I just came across this and was unable to find applicationpoolidentity as an account in order to add it to the folder security. I changed the application pool identity from applicationpoolidentity to Local Service and the site ran fine.
I was copying a live WordPress site to my local machine for editing/updating when this IIS error occurred. Changing permissions did nothing.
In my case, simply deleting the web.config did the trick.
I ran into this issue again today. This time, no amount of granting permissions worked (tried all the usual accounts, everybody, read-only, modify, full control).
Closed processes, restarted IIS, full reboot. No results.
Eventually changed the owner from "Administrators" to myself, and things fell into place.
I usually run Visual Studio at Admin level (using my own account) because I like to use the local IIS for hosting / debugging ASP.NET sites. Perhaps that caused new files to be owned by \Administrators, which in turn may have limited access to those files by the IIS or App Pool processes.
My DefaultAppPool identity is set to load the user profile. I don't know at what point the session manager applies UAC / permissions drops and whether user profile loading has any influence on this. Food for thought...

System.UnauthorizedAccessException: Access to the path is denied

No matter what I do such as give Network Service and the ASP.NET account full rights to the folder that contains the image, I am still getting this error for a System.IO.File.Move. Anyone know what other accounts I may be missing here? Network Service is the account running the app pool under which this site runs on and I gave Network Service full rights to the entire folder.
I've tried everything. I gave Network Service and the machinename\aspnet full permissions to the folder that contains this .jpg. I'm testing this code and this move on localhost...my developer machine.
Have you tried using SysInternals FileMon now part of Process Monitor. You can use it to watch for the file access events or the access denied event.
It might be because you write into some other folder that is not under the ASP.NET application (eg %TEMP% folder or something). In this case the account used is IUSR_MACHINENAME which represents anonymous user.
You either need to impersonate, use another folder or give write privileges to IUSR_XXX (which I don't think is a good idea) to deal with that.
On the machine hosting the shared drive, make sure to set things up under both these tabs:
Sharing -> Permissions
Security
Most of us deal with the Security tab for getting IIS stuff working, but it was the former that was giving me the same issue with the .MoveTo() method. (It could read, just not move).
To further complicate matters, I also had the directory shared as multiple names - make sure to check the permissions for each shared name.

ASP.NET + Access to the path is denied

I have an ASP.NET application that attempts to write files on the web server during runtime. In my development environment, this works. However, when I deploy it to the production server, and I execute the code, I receive an error that states:
"Access to the path 'C:\Inetpub\wwwroot\MyWebApp\DirToWriteTo\' is denied."
My production server is a Window Server 2003 machine. The web application is set to allow anonymous access via the IUSR_TEMPLATE account.
What am I doing wrong?
Thank you!
You need provide the grant permissions to NETWORK SERVICE user.
you can check this link:-
http://repeatgeek.com/technical/asp-net-access-to-path-is-denied/
The most likely problem is that your anonymous user does not have write access to the location.
What I would do is create a web.config entry for the location you want to write to and use that config key as your writable directory. This will allow you to have separate configuration for your production server and your development machine, if needed.
Next, just give write access to the directory defined in your configuration to the user IUSER_TEMPLATE, or as Thorarin said the Network Service, in which case you should set up identity impersonation in your Web.config so that you can specify the user (unless you configure the user through the app pool). That should fix the problem.
If you have Windows 2008 or above, try giving write permissions to IIS_IUSRS.
(Network Service has also worked for me in the past. From what I read here, it depends on the Server OS.)
In my case, Visual Studio 2015 changed an existing project's IIS AppPool user to the default of DefaultAppPool, which gave me permission errors, configuration errors, role provider errors, and null reference errors. After discovering this and changing it back to the application pool that the folder permissions were set to, things started working again.

Resources