Skip to content

The Dummy Programmer

Stories of daily programming

  • Home
  • My other dummy projects
  • Games
    • Space Y: An Asteroids clone
  • Services
    • What’s my user agent
    • What’s my IP address
  • About
  • Toggle search form

Configure access permission to a folder for an IIS Application pool

Posted on September 24, 2019September 24, 2019 By

Suppose you are developing an ASP.NET application and you have to configure write permissions to a certain folder, maybe because you use it as temporary folder to write some data.

You don’t want to assign “Everyone – Full control” to the folder because you want to be the most restrictive possibile.

Following I’m explaining to you step by step how you can do this…

In IIS 7.5 and greater, you have to assign permissions to the user which runs your application pool.

Usually, when you create a web application in IIS, IIS also automatically creates a new application pool with the same name.

As you can see in the sample below, I created a new application named “TestApp”.

IIS Application Example

Now click on “Application Pools” and you will see an application pool with the same name:

IIS Application Pool

 

By default, an application pool runs under the Identity “ApplicationPoolIdentity”, as you can see in the “Identity” column.

Now create a new folder under “C:” named “TempFolder”.

TempFolder under C:\

 

Select the folder, click the right mouse button, click on “Properties” and then click on the “Security” tab.

First of all I want to remove all the default permissions, except for the Administrators group and my current logged user, which of course is an administrator too. To do this, click on the button “Advanced”, and click on the button “Disable inheritance”.

Advanced Security

Then in the tab “Security” remove all the gruop and users, except the group “Administrators”.

Only administrators

I created an ASP.NET page that opens and writes a file in the folder with the newly configured permissions.

ASP.NET Page

This is the code of the click “Event” of the “Write file” button.

protected void Button1_Click(object sender, EventArgs e)
{
   StreamWriter SW = new StreamWriter(@"C:\TempFolder\MyFile.txt");
   SW.Write("This is a test row!");
   SW.Close();
}

Trying to click the button, you will get an access denied error:

Access denied

To solve the problem, go back to the permission window of the folder and click the “Add…” button:

Add Permissions

You will see the following window:

Select users or groups

In the “Enter the object names to select” insert the string “IIS AppPool\TestApp” and click “Check names”.

Note that “TestApp” is the name of the application pool under which the web application run. This name will be different in your case.

Select users or groups

Now press “OK” to close the window. You will see a new user “TestApp” in the “Group or user names” list. Be sure to check the permission “Full control” – “Allow”, then press “OK”.

TestApp added

After this, if you take again the test page and click on the “Write file” button, the file will be correctly created!

Hope this helps!

Bye bye!!

 

 

ASP.NET, ASP.NET MVC

Post navigation

Previous Post: How to know who is blocking a query in Sql Server
Next Post: Sql Server: apply an aggregate function to fields values in a row

Related Posts

WebResource.axd (404) not found ASP.NET
ASP.NET MVC5 Security Exception on Aruba provider ASP.NET MVC
NPOI and Excel found unreadable content in ‘[filename].xls’ ASP.NET
Telerik RadGrid rendering problems with IE11 in compatibility mode ASP.NET
Put an ASP.NET website under maintenance ASP.NET
HTTP 500 – Internal server error in an ASP.NET application ASP.NET

Search

Related posts

  • Create a folder starting with dot in Windows
  • Quickly open the startup folder in Windows 10
  • Failed to decode downloaded font: (your web…
  • Run an old Apache ASP web application in Ubuntu 20.04

Categories

  • .NET 6 (1)
  • .NET 7 (1)
  • AJAX (1)
  • Android (2)
  • Apache (4)
  • ASP.NET (9)
  • ASP.NET MVC (3)
  • Avalonia UI (1)
  • BCP (1)
  • Bitlocker (2)
  • C# (14)
  • CentOS (4)
  • ClosedXML (1)
  • CLR (1)
  • DNS (1)
  • Encryption (3)
  • Excel (2)
  • FuelPHP (3)
  • Games (2)
  • Google Chrome (1)
  • GSuite (1)
  • HTML (1)
  • Imagick (2)
  • Javascript (1)
  • Kindle (1)
  • LAMP (3)
  • Linux (7)
  • MariaDB (2)
  • Mathematics (2)
  • MySql (4)
  • NPOI (1)
  • Office 365 (1)
  • Perl (1)
  • PHP (6)
  • Programming (1)
  • Remote desktop (1)
  • SFTP (2)
  • Sockets (3)
  • Sql Server (20)
  • Sql Server 2016 (14)
  • Sql Server 2019 (1)
  • SSL (4)
  • Task scheduler (1)
  • Telerik ASP.NET AJAX (2)
  • The Dummy Programmer Chat (2)
  • Threading (5)
  • Tools (1)
  • TPL (3)
  • TypeScript (3)
  • Ubuntu (4)
  • Virtualization software (3)
  • Visual Studio (1)
  • Visual Studio Code (2)
  • VueJS (1)
  • Web fonts (1)
  • Web programming (6)
  • Windows (12)
  • Windows 10 (15)
  • Windows Forms (1)
  • Windows Server (6)

Copyright © 2024 The Dummy Programmer | Privacy Policy | Terms of use |

Powered by PressBook Masonry Dark

Manage Cookie Consent
This site doesn’t collect user personal data and doesn’t install profiling or analytical cookies, either its own or from third parties. Read our privacy policy for more info.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}