By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,421 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Accessing Files In 'App_Data' Folder

P: n/a
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'. Finally, I redirect the page to
that file in order to serve it out (push the download) to the user.
This all worked great in .net v1.1.

Now, in my new .net v2 app, everytime the page redirect occurs, the
browser displays "The webpage cannot be found." I have verified that
the file is located in 'App_Data' folder. I have also verified that
the redirect is going to the correct URL. I even tried manually typing
the URL ("http://localhost/App_Data/Temp/MyFile.csv") into the browser
- same result.

I also thought this problem might be occurring due to IIS not having a
mapping for the CSV filetype, so went to the IIS snap in and added it.
I basically used the same aspnet DLL file and verbs as for the aspx
pages. After stopping and restarting the site, it still gives the "The
webpage cannot be found" message.

What can I do to make this work?

May 31 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On May 31, 3:36 pm, Joey <joey.pow...@topscene.comwrote:
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'. Finally, I redirect the page to
that file in order to serve it out (push the download) to the user.
This all worked great in .net v1.1.

Now, in my new .net v2 app, everytime the page redirect occurs, the
browser displays "The webpage cannot be found." I have verified that
the file is located in 'App_Data' folder. I have also verified that
the redirect is going to the correct URL. I even tried manually typing
the URL ("http://localhost/App_Data/Temp/MyFile.csv") into the browser
- same result.

I also thought this problem might be occurring due to IIS not having a
mapping for the CSV filetype, so went to the IIS snap in and added it.
I basically used the same aspnet DLL file and verbs as for the aspx
pages. After stopping and restarting the site, it still gives the "The
webpage cannot be found" message.

What can I do to make this work?
Why are you saving into App_Data? App_Data is a system .NET folder
and those files are protected in there.

Just create a regular folder and save them in there.

May 31 '07 #2

P: n/a

I concur.

Don't use App_Data for temp files.

App_Data would have:
myaccess.mdb
myfile.xml
sqlexpressfile.db (whats the extension??)

type files in it. Not temp files.


"Larry Bud" <la**********@yahoo.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
On May 31, 3:36 pm, Joey <joey.pow...@topscene.comwrote:
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'. Finally, I redirect the page to
that file in order to serve it out (push the download) to the user.
This all worked great in .net v1.1.

Now, in my new .net v2 app, everytime the page redirect occurs, the
browser displays "The webpage cannot be found." I have verified that
the file is located in 'App_Data' folder. I have also verified that
the redirect is going to the correct URL. I even tried manually typing
the URL ("http://localhost/App_Data/Temp/MyFile.csv") into the browser
- same result.

I also thought this problem might be occurring due to IIS not having a
mapping for the CSV filetype, so went to the IIS snap in and added it.
I basically used the same aspnet DLL file and verbs as for the aspx
pages. After stopping and restarting the site, it still gives the "The
webpage cannot be found" message.

What can I do to make this work?

Why are you saving into App_Data? App_Data is a system .NET folder
and those files are protected in there.

Just create a regular folder and save them in there.

May 31 '07 #3

P: n/a
On May 31, 2:47 pm, "sloan" <s...@ipass.netwrote:
I concur.

Don't use App_Data for temp files.

App_Data would have:
myaccess.mdb
myfile.xml
sqlexpressfile.db (whats the extension??)

type files in it. Not temp files.

"Larry Bud" <larrybud2...@yahoo.comwrote in message

news:11**********************@q75g2000hsh.googlegr oups.com...
On May 31, 3:36 pm, Joey <joey.pow...@topscene.comwrote:
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'. Finally, I redirect the page to
that file in order to serve it out (push the download) to the user.
This all worked great in .net v1.1.
Now, in my new .net v2 app, everytime the page redirect occurs, the
browser displays "The webpage cannot be found." I have verified that
the file is located in 'App_Data' folder. I have also verified that
the redirect is going to the correct URL. I even tried manually typing
the URL ("http://localhost/App_Data/Temp/MyFile.csv") into the browser
- same result.
I also thought this problem might be occurring due to IIS not having a
mapping for the CSV filetype, so went to the IIS snap in and added it.
I basically used the same aspnet DLL file and verbs as for the aspx
pages. After stopping and restarting the site, it still gives the "The
webpage cannot be found" message.
What can I do to make this work?
Why are you saving into App_Data? App_Data is a system .NET folder
and those files are protected in there.
Just create a regular folder and save them in there.- Hide quoted text -

- Show quoted text -
Okay, maybe I am misunderstanding something here. In the old asp.net
v1.1 app, I did just what you said. I created sub folders off of
whatever folders contained the webpages, and then I put my files in
there before redirecting to them. Like I said, that used to work
great.

Then a few weeks ago I started working with asp.net v2. When I tried
that same approach, I kept losing Session data everytime I deleted/
(and wrote?) files to those same old temp folders.

After troubleshooting this, I found out that in asp.net v2 when one
deletes/(and writes?) files/folders outside of the App_Data folder, it
causes something called an AppDomain restart - and this invalidates
all Session data. THIS IS HUGE!!!

For this reason, I started moving all of my stuff to the App_Data
folder.

So you guys are saying you have never heard about the AppDomain
restart problem before? Has anyone else heard of it?

If I can't write and delete files outside of the App_Data folder, and
I can't do it inside of the App_Data folder either, where else is
left?

Any suggestions/feedback/comments are appreciated.

Thanks,
JP

May 31 '07 #4

P: n/a

Hmm.

I see your issue and concur it is a signficant one.

However, I have deployed an app in 2.0 where I did what (we) described.

My was

/root/
/root/Reports/
/root/Reports/TempReportFiles/

and I was creating files in there. And didn't suffer the restart issue.

Are you running the built in webserver, or using IIS?

Try going to IIS and see if you get the same issues.

(Aka, you won't have mydevelpmentsite:5097/ port number thing in IIS)

Its under the project properties (to change to IIS)

"Joey" <jo*********@topscene.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
On May 31, 2:47 pm, "sloan" <s...@ipass.netwrote:
I concur.

Don't use App_Data for temp files.

App_Data would have:
myaccess.mdb
myfile.xml
sqlexpressfile.db (whats the extension??)

type files in it. Not temp files.

"Larry Bud" <larrybud2...@yahoo.comwrote in message

news:11**********************@q75g2000hsh.googlegr oups.com...
On May 31, 3:36 pm, Joey <joey.pow...@topscene.comwrote:
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'. Finally, I redirect the page
to
that file in order to serve it out (push the download) to the user.
This all worked great in .net v1.1.
Now, in my new .net v2 app, everytime the page redirect occurs, the
browser displays "The webpage cannot be found." I have verified that
the file is located in 'App_Data' folder. I have also verified that
the redirect is going to the correct URL. I even tried manually
typing
the URL ("http://localhost/App_Data/Temp/MyFile.csv") into the
browser
- same result.
I also thought this problem might be occurring due to IIS not having
a
mapping for the CSV filetype, so went to the IIS snap in and added
it.
I basically used the same aspnet DLL file and verbs as for the aspx
pages. After stopping and restarting the site, it still gives the
"The
webpage cannot be found" message.
What can I do to make this work?
Why are you saving into App_Data? App_Data is a system .NET folder
and those files are protected in there.
Just create a regular folder and save them in there.- Hide quoted
text -

- Show quoted text -

Okay, maybe I am misunderstanding something here. In the old asp.net
v1.1 app, I did just what you said. I created sub folders off of
whatever folders contained the webpages, and then I put my files in
there before redirecting to them. Like I said, that used to work
great.

Then a few weeks ago I started working with asp.net v2. When I tried
that same approach, I kept losing Session data everytime I deleted/
(and wrote?) files to those same old temp folders.

After troubleshooting this, I found out that in asp.net v2 when one
deletes/(and writes?) files/folders outside of the App_Data folder, it
causes something called an AppDomain restart - and this invalidates
all Session data. THIS IS HUGE!!!

For this reason, I started moving all of my stuff to the App_Data
folder.

So you guys are saying you have never heard about the AppDomain
restart problem before? Has anyone else heard of it?

If I can't write and delete files outside of the App_Data folder, and
I can't do it inside of the App_Data folder either, where else is
left?

Any suggestions/feedback/comments are appreciated.

Thanks,
JP

May 31 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.