How to Set File Permissions for ASP.NET Website on Windows

Problem:

  • You have ASP.NET website on Windows.
  • Your website application pool name is mysite.com.
  • Your website physical location is D:\inetpub\wwwroot\mysite.com.
  • Your website physical data location is D:\mysite_data.
  • Your website users cannot upload or modify website files.
  • Your website users cannot upload or modify website data files.

Solution:

1. Open cmd.exe as Administrator and execute the command below.

icacls "D:\inetpub\wwwroot\mysite.com" /grant "IIS AppPool\mysite.com":(OI)(CI)F /T
icacls "D:\mysite_data" /grant "IIS AppPool\mysite.com":(OI)(CI)F /T

This command give full permissions against D:\inetpub\wwwroot\mysite.com  and all sub-directories and files, and against D:\mysite_data  and all sub-directories and files to mysite.com user.

2. Alternatively you can execute the command below.

icacls "D:\inetpub\wwwroot\mysite.com" /grant IIS_IUSRS:F /t
icacls "D:\mysite_data" /grant IIS_IUSRS:F /t

This command give full permissions against D:\inetpub\wwwroot\mysite.com  and all sub-directories and files, and against D:\mysite_data  and all sub-directories and files to IIS_IUSRS group.

mysite.com user is part of the IIS_IUSRS group.

 

How to Restart a Windows Server in a Domain Remotely

Problem:

You need to restart a Windows server in a domain remotely because it seems to be stuck and you cannot remotely connect to it via RDP.

Solution:

1. Open cmd.exe and execute 2 commands below.

ping server_name
shutdown /r /m \\server_name /t 0/

2. You may get the error below.

server_name: A system shutdown is in progress.(1115)

3. Download and extract PSTools.

4. Open cmd.exe and execute 3 commands below.

cd C:\Users\admin\Downloads\PSTools
pskill \\server_name winlogon
pskill \\server_name TrustedInstaller