Every time I install my web app, I have to manually set Write permissions to two folders. I got to thinking that the global "Application_Start" method could do this for me automatically. Here's my initial attempt to do this with the root-level "Logs" folder:
Please let me know if there is anything that I can do to help.
best regards,
Angie
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
In my case, it's overkill to create an MS Build setup file. Instead I just Zip up the published files and me or my client unzips them into the 'wwwroot' app folder. Then Write permissions on two folders have to be set each time (because the folders are
erased).
I was just hoping for a simple way to automate this.
Store your logs outside of your website folders, or store them inside the app_data folder. Keeping log files in website folders is a bad idea for numerous reasons, you are risking app recycling and it is also a security risk.
I'm afraid I no longer use this forum due to the new point allocation system.
Member
10 Points
145 Posts
Is there a programmatic way to set Write permissions to my app's folders?
Sep 16, 2014 09:23 PM|pelalusa|LINK
Every time I install my web app, I have to manually set Write permissions to two folders. I got to thinking that the global "Application_Start" method could do this for me automatically. Here's my initial attempt to do this with the root-level "Logs" folder:
It doesn't cause an error but when I check whether "IIS_IUSRS" has Write privileges for the "Logs" folder, it does not.
Is there a correct way to do this?
Robert
All-Star
26071 Points
5892 Posts
Re: Is there a programmatic way to set Write permissions to my app's folders?
Sep 16, 2014 09:42 PM|markfitzme|LINK
Yeah it shouldn't be able to do this. Think of how bad this could go if web apps were allowed to to this.
You can use PowerShell to handle this though. Here is an example of setting ACLs on a directory: http://blogs.msdn.com/b/johan/archive/2008/10/01/powershell-editing-permissions-on-a-file-or-folder.aspx
Member
10 Points
145 Posts
Re: Is there a programmatic way to set Write permissions to my app's folders?
Sep 18, 2014 10:15 AM|pelalusa|LINK
So you're saying that every time I install a new version of my app, I have to manually change the Write permissions of the two folders?
Surely there must be a way to automate this?!
All-Star
32817 Points
3815 Posts
Re: Is there a programmatic way to set Write permissions to my app's folders?
Sep 26, 2014 04:52 AM|Angie xu - MSFT|LINK
Hi pelalusa,
I check relevant topic about this write permissions issue online, we can set folder permissions manually or you can make it an automatic part of the deployment process. Making it automatic requires complex MSBuild code, and since you only have to do this the first time you deploy, this tutorial only shows how to do it manually. See: http://www.asp.net/mvc/tutorials/deployment/deployment-to-a-hosting-provider/deployment-to-a-hosting-provider-setting-folder-permissions-6-of-12
Please let me know if there is anything that I can do to help.
best regards,
Angie
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
10 Points
145 Posts
Re: Is there a programmatic way to set Write permissions to my app's folders?
Sep 26, 2014 09:18 AM|pelalusa|LINK
Hi Angie,
Yes, I know how to do it manually.
In my case, it's overkill to create an MS Build setup file. Instead I just Zip up the published files and me or my client unzips them into the 'wwwroot' app folder. Then Write permissions on two folders have to be set each time (because the folders are erased).
I was just hoping for a simple way to automate this.
Robert
All-Star
48570 Points
18086 Posts
Re: Is there a programmatic way to set Write permissions to my app's folders?
Jan 23, 2015 04:26 AM|PatriceSc|LINK
Hi,
How is this automated? You could use https://technet.microsoft.com/en-us/library/bb490872.aspx maybe or PowerShell or the IIS management DLL from a C# app...
The main point is that the account that does the change need to be allowed to do that (which is likely why you couldn't do that from the app itself).
All-Star
37441 Points
9076 Posts
Re: Is there a programmatic way to set Write permissions to my app's folders?
Jan 23, 2015 04:57 AM|AidyF|LINK
Store your logs outside of your website folders, or store them inside the app_data folder. Keeping log files in website folders is a bad idea for numerous reasons, you are risking app recycling and it is also a security risk.