Say you have a public ASP.NET (or Classic ASP) application on IIS with a script/page that needs to write or update files in a specific folder that is located within the web publishing folder tree.
1) What is the proper way to set this up?
My main concern is that I want to let the ASP/ASP.NET apps write to a folder, but I don't want regular http users to be able to PUT files into it.
First let me start by saying, I'm a pretty big believer that there is almost always a better solution than writing stuff out to disk. Whether it's writting the data to a database, or feeding web services, writing out to disk should be the last option.
That being said there are some valid reasons, but this is sort of tricky and dependent on why the app needs to write out the files.
Having the data written outside of where code is running from is an absolute requirement. Allowing end users to write to a path where the ASPX/asp engines can interpret/execute code is bad for obvious reasons.
Some other things that impact this are:
The App_Data Folder
To improve the security of the data used by your ASP.NET application, a new subfolder named App_Data has been added for ASP.NET applications. Files stored in the App_Data folder are not returned in response to direct HTTP requests, which makes the App_Data folder the recommended location for data stored with your application, including .mdf (SQL Server Express Edition), .mdb (Microsoft Access), or XML files. Note that when using the App_Data folder to store your application data, the identity of your application has read and write permissions to the App_Data folder.
What's new in ASP.NET Data Access
Probably betting to look over on stackoverflow.com...
Best practice is to put that folder OUTSIDE of your document root and have your app read from the file system. Otherwise, make the folder read-only except to the ASP[.NET] user and control the write priviliges with your app's internal authorizations.
App_Data is, by default, writable but not readable. The server seems to resist any attempt to change this. Thus, it is better to make a completely new folder and change the permissions on it to NOT EXECUTABLE and READABLE and WRITABLE.