473,378 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how does the app_data folder work

Hi,

From what I can gather, under Asp.Net 2.0, it is safe to put data and config
files underneath the app_data in the web root and they will not be served
directly to the browser from a URL.

Can anyone explain just how this feature works. is app_data a reserved name
for IIS and ASP.Net, or is there some jiggery pokery going on behind the
scenes with file permissions or virtual roots?

It's not that I don't trust Microsoft; it's just that .... well.... I guess
I don't trust Microsoft - especially where bits of unexplained magic are
concerned :-)

TIA

Andy
Sep 10 '07 #1
6 29428
re:
!is app_data a reserved name for IIS and ASP.Net

No, it's not.

The files which are not served are set in the master web.config file, in the
<httpHandlerssection, managed by System.Web.HttpForbiddenHandler.

That m,aster web.config file is located at :
drive:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ CONFIG\web.config

Examples :

<add path="*.mdb" verb="*" type="System.Web.HttpForbiddenHandler" validate="True" />
<add path="*.ldb" verb="*" type="System.Web.HttpForbiddenHandler" validate="True" />
<add path="*.mdf" verb="*" type="System.Web.HttpForbiddenHandler" validate="True" />
<add path="*.ldf" verb="*" type="System.Web.HttpForbiddenHandler" validate="True" />

You can add any other file extensions you don't want
ASP.NET to serve directly by following that format.

re:
!is there some jiggery pokery going on behind the scenes with file permissions or virtual roots?

There's also some jiggery pokery going on behind the scenes with file permissions or virtual roots.

If you create a Web site in Visual Web Developer (whether the standalone or the VS IDE),
VWD creates a folder named App_Data below the current root folder.

The folder is designed to be a store for application data of any type.

The App_Data folder is also used by ASP.NET to store databases that the system maintains,
such as the database for membership and roles.

When VWD creates the App_Data folder, it grants Read and Write permissions
for the folder to the ASPNET or NETWORK SERVICE user account.

So, if a request is made from an external browser for a forbidden file,
the account requesting it won't be the ASPNET or NETWORK SERVICE accounts,
which are the only ones which are allowed access to those files.

There's no "unexplained magic" involved.
It's all pretty much straightforward.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Andy Fish" <aj****@blueyonder.co.ukwrote in message news:uK*************@TK2MSFTNGP06.phx.gbl...
Hi,

From what I can gather, under Asp.Net 2.0, it is safe to put data and config files underneath the app_data in the web
root and they will not be served directly to the browser from a URL.

Can anyone explain just how this feature works. is app_data a reserved name for IIS and ASP.Net, or is there some
jiggery pokery going on behind the scenes with file permissions or virtual roots?

It's not that I don't trust Microsoft; it's just that .... well.... I guess I don't trust Microsoft - especially where
bits of unexplained magic are concerned :-)

TIA

Andy


Sep 10 '07 #2
Thanks for the reply, but I still don't really get it

let's say I create a new web site (just using explorer and IIS admin - not
visual web developer) with a one folder called foo and one called app_data

inside each folder I place a file with an unknown extension not mentioned in
the global web.config - say foo.bar

I can access http://localhost/mysite/foo/foo.bar but not
http://localhost/mysite/app_data/foo.bar even though the file permissions
are the same

so surely there must be some magic going on behind the scenes somewhere?

Andy

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
re:
!is app_data a reserved name for IIS and ASP.Net

No, it's not.

The files which are not served are set in the master web.config file, in
the
<httpHandlerssection, managed by System.Web.HttpForbiddenHandler.

That m,aster web.config file is located at :
drive:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ CONFIG\web.config

Examples :

<add path="*.mdb" verb="*" type="System.Web.HttpForbiddenHandler"
validate="True" />
<add path="*.ldb" verb="*" type="System.Web.HttpForbiddenHandler"
validate="True" />
<add path="*.mdf" verb="*" type="System.Web.HttpForbiddenHandler"
validate="True" />
<add path="*.ldf" verb="*" type="System.Web.HttpForbiddenHandler"
validate="True" />

You can add any other file extensions you don't want
ASP.NET to serve directly by following that format.

re:
!is there some jiggery pokery going on behind the scenes with file
permissions or virtual roots?

There's also some jiggery pokery going on behind the scenes with file
permissions or virtual roots.

If you create a Web site in Visual Web Developer (whether the standalone
or the VS IDE),
VWD creates a folder named App_Data below the current root folder.

The folder is designed to be a store for application data of any type.

The App_Data folder is also used by ASP.NET to store databases that the
system maintains,
such as the database for membership and roles.

When VWD creates the App_Data folder, it grants Read and Write permissions
for the folder to the ASPNET or NETWORK SERVICE user account.

So, if a request is made from an external browser for a forbidden file,
the account requesting it won't be the ASPNET or NETWORK SERVICE accounts,
which are the only ones which are allowed access to those files.

There's no "unexplained magic" involved.
It's all pretty much straightforward.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Andy Fish" <aj****@blueyonder.co.ukwrote in message
news:uK*************@TK2MSFTNGP06.phx.gbl...
>Hi,

From what I can gather, under Asp.Net 2.0, it is safe to put data and
config files underneath the app_data in the web root and they will not be
served directly to the browser from a URL.

Can anyone explain just how this feature works. is app_data a reserved
name for IIS and ASP.Net, or is there some jiggery pokery going on behind
the scenes with file permissions or virtual roots?

It's not that I don't trust Microsoft; it's just that .... well.... I
guess I don't trust Microsoft - especially where bits of unexplained
magic are concerned :-)

TIA

Andy



Sep 11 '07 #3
Hi, Andy.

re:
!so surely there must be some magic going on behind the scenes somewhere?

Not quite "magic" but, yes, any data files you put
in the App_Data folder will be protected by default.

No external http requests for any file there will be honored.

What I tried to say was that the mechanism has nothing
to do with "reserved names", as you suggested it might.

There *is*, however an internal check for the source of the request.
If the request for a file in App_Data is external to the server, the file won't get served.

re:
!inside each folder I place a file with an unknown extension
!not mentioned in the global web.config - say foo.bar

If you want *.bar files protected, you'd have to add :

<add path="*.bar" verb="*" type="System.Web.HttpForbiddenHandler" validate="True" />

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Andy Fish" <aj****@blueyonder.co.ukwrote in message news:e3**************@TK2MSFTNGP04.phx.gbl...
Thanks for the reply, but I still don't really get it

let's say I create a new web site (just using explorer and IIS admin - not visual web developer) with a one folder
called foo and one called app_data

inside each folder I place a file with an unknown extension not mentioned in the global web.config - say foo.bar

I can access http://localhost/mysite/foo/foo.bar but not http://localhost/mysite/app_data/foo.bar even though the file
permissions are the same

so surely there must be some magic going on behind the scenes somewhere?

Andy

"Juan T. Llibre" <no***********@nowhere.comwrote in message news:%2***************@TK2MSFTNGP02.phx.gbl...
>re:
!is app_data a reserved name for IIS and ASP.Net

No, it's not.

The files which are not served are set in the master web.config file, in the
<httpHandlerssection, managed by System.Web.HttpForbiddenHandler.

That m,aster web.config file is located at :
drive:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 \CONFIG\web.config

Examples :

<add path="*.mdb" verb="*" type="System.Web.HttpForbiddenHandler" validate="True" />
<add path="*.ldb" verb="*" type="System.Web.HttpForbiddenHandler" validate="True" />
<add path="*.mdf" verb="*" type="System.Web.HttpForbiddenHandler" validate="True" />
<add path="*.ldf" verb="*" type="System.Web.HttpForbiddenHandler" validate="True" />

You can add any other file extensions you don't want
ASP.NET to serve directly by following that format.

re:
!is there some jiggery pokery going on behind the scenes with file permissions or virtual roots?

There's also some jiggery pokery going on behind the scenes with file permissions or virtual roots.

If you create a Web site in Visual Web Developer (whether the standalone or the VS IDE),
VWD creates a folder named App_Data below the current root folder.

The folder is designed to be a store for application data of any type.

The App_Data folder is also used by ASP.NET to store databases that the system maintains,
such as the database for membership and roles.

When VWD creates the App_Data folder, it grants Read and Write permissions
for the folder to the ASPNET or NETWORK SERVICE user account.

So, if a request is made from an external browser for a forbidden file,
the account requesting it won't be the ASPNET or NETWORK SERVICE accounts,
which are the only ones which are allowed access to those files.

There's no "unexplained magic" involved.
It's all pretty much straightforward.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Andy Fish" <aj****@blueyonder.co.ukwrote in message news:uK*************@TK2MSFTNGP06.phx.gbl...
>>Hi,

From what I can gather, under Asp.Net 2.0, it is safe to put data and config files underneath the app_data in the
web root and they will not be served directly to the browser from a URL.

Can anyone explain just how this feature works. is app_data a reserved name for IIS and ASP.Net, or is there some
jiggery pokery going on behind the scenes with file permissions or virtual roots?

It's not that I don't trust Microsoft; it's just that .... well.... I guess I don't trust Microsoft - especially
where bits of unexplained magic are concerned :-)

TIA

Andy




Sep 11 '07 #4
>
There *is*, however an internal check for the source of the request.
If the request for a file in App_Data is external to the server, the file
won't get served.
So just to confirm, the special processing of the app_data folder is a rule
hard-coded into IIS - correct ?
Sep 11 '07 #5
re:
!So just to confirm, the special processing of
!the app_data folder is a rule hard-coded into IIS - correct ?

Hard-coded into ASP.NET, more precisely.
It's an ASP.NET check which prevents the files from getting served by IIS.

IIS never even knows the file was requested.
ASP.NET checks...and doesn't send IIS the request.

ASP.NET is an ISAPI filter which sits between the client and IIS,
passing data requests to IIS, after processing them with its rules.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Andy Fish" <aj****@blueyonder.co.ukwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...

There *is*, however an internal check for the source of the request.
If the request for a file in App_Data is external to the server, the file won't get served.

So just to confirm, the special processing of the app_data folder is a rule hard-coded into IIS - correct ?


Sep 11 '07 #6
thanks for the info - I get it now :-)

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:O0**************@TK2MSFTNGP06.phx.gbl...
re:
!So just to confirm, the special processing of
!the app_data folder is a rule hard-coded into IIS - correct ?

Hard-coded into ASP.NET, more precisely.
It's an ASP.NET check which prevents the files from getting served by IIS.

IIS never even knows the file was requested.
ASP.NET checks...and doesn't send IIS the request.

ASP.NET is an ISAPI filter which sits between the client and IIS,
passing data requests to IIS, after processing them with its rules.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Andy Fish" <aj****@blueyonder.co.ukwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>
There *is*, however an internal check for the source of the request.
If the request for a file in App_Data is external to the server, the
file won't get served.

So just to confirm, the special processing of the app_data folder is a
rule hard-coded into IIS - correct ?



Sep 12 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hugo Flores | last post by:
I created a Web Application Project in VS 2005. The site is working fine in the development computer. Then I transfer all my files and dll to the production computer. I have a login form. If I try...
5
by: CharlesA | last post by:
hi folks I'm working on reverse engineering TheBeerHouse by Marco Bellinaso which appears to have 100% unanimous approval on Amazon. I got the book and downloaded the code and I opened the...
2
by: Artificer | last post by:
Why by simply having a .mdf file in the app_data folder it is made accessible? Does placing a .mdf in the app_data folder does some kind of attachment? Do this pseudo attachment works only with the...
2
by: Artificer | last post by:
Why by simply having a .mdf file in the app_data folder it is made accessible? Does placing a .mdf in the app_data folder does some kind of attachment? Do this pseudo attachment works only with the...
5
by: wwwmike | last post by:
I have an asp.net 2.0 application where I move about 200,000 text files daily in and out. When using VS 2005 to debug my application everything works find if only a few files are in the folder....
4
by: Joey | last post by:
asp.net 2/C#/VS2005 I have a web app where I use a stream writer to create a CSV (text) file. I then use my code to save the file in the site's 'App_Data' folder, in a subfolder called 'Temp'....
3
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
Is it always necessary to upload to the host, the App_Data folder if my db does not reside in that folder? -- L. A. Jones
3
by: Ian Semmel | last post by:
I want to write files to the directory /App_Data/XML/ on my web hosting server but get access denied. What user am I supposed to give access rights to ? My Membership stuff is all done via a...
0
by: Munna | last post by:
Hi Since you using 3.5 and vs2008 you can add wcf service directly in your web application... Well you can always write code to access the App_data folder if have your own control hosting...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.