Re: Question About Design Strategy
- From: "sloan" <sloan@xxxxxxxxx>
- Date: Thu, 27 Sep 2007 11:07:44 -0400
An idea:
When the code runs to copy the file, don't have the user "wait".
Send them to a page, that is a polling page, and checks (every 10 seconds)
to see if the file they requested has finished downloading.
You can do this with a small database (flags that say "DownloadStarted",
"DownloadComplete") or something in Session state or something like that.
I use this scenario with reports. (for like 4 years now)
I actually let the user input report parameters, and then a windows service
picks up the request, and creates a .html file.
The html file may or may not be big, but the report processing time may be
long. Thus the "dont make me wait" strategy.
I actually (when I copy the file) use a guid/guid solution.
www.mysitecom/customerreports/A4D76F2D5AE5452b89BCD9414F481893/D9D229195C0D4c22923F786686093D4F.html
There are 2 guid's there, one for a directory, one for a file. I figure the
odds of guessing a filename with 2 guid's in it are pretty low.
PS The Guid.ToString("N") comes in handy here.
Naturally, you have to have a cleanup service. I check the lastmodified
date attribute of the file, and have a configurable value like "4" (for 4
hours) to go delete them out.
So that's an idea.
You have to figure out how anal your security scenario is.
The above solution..... someone can send a link to the file, that will work
for 4 hours. Maybe that's ok, maybe that's not ok.
In a banking scenario, you probably want to stream an image every single
time, ... like for a check image or something.
........
Seperately, I would strongly suggest looking at Jeff Prosise's example
http://www.wintellect.com/webdemos.aspx
Asynchronous ASP.NET
Find
NorthwindImageGrabber : IHttpHandler
The project first shows how to use a IHttpHandler instead of using an aspx
page. (This was Jeff's big NO-NO at TechEd2007, don't use an aspx page to
stream images)
It doesn't play into my solution above necessarily, its just a new thing to
consider when figuring out a solution.
"Joey" <joey.powell@xxxxxxxxxxxx> wrote in message
news:1190901568.778300.315820@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have written an app in C#/asp.net 2.0 that is a system built to
handle a large number of scenarios. Part of that system involves
allowing users to download large files. As part of my original design
strategy, I chose to locate these downloads in a directory separate
from the website file structure.
The two primary purposes for this were: (1) it is more secure because
users cannot link directly to the files and (2) it is modular,
allowing for complete refreshes/updates of the application code
without having to worry about deleting this directory and files.
To accomodate this, I created an appSettings key/value pair (along
with many others) in my web.config file to hold the path/location of
this external directory. Then I added a .cs file to my App_Code
directory that contains a static class called "Website" that reads all
the values and makes them available to the application during run
time. For example, after the app starts, a code behind page might get
the needed value with a call like "Website.DownloadsDirectory".
Next I created a web form whose only purpose is to "fetch" the file,
copy it to a temporary directory (within the website file structure),
and then Response.Redirect to it. The temporary directory itself is
purged periodically by the app, so these temporary files don't remain
in there forever.
Anyways, this all works great for small files...then we started trying
to do it with big files. When I say big, I mean over 1GB. As you might
imagine, we are now having problems. Here's what happens...(1) The
user clicks the Download link (2) then the "fetch" page kicks off and
begins copying the file into the temporary directory. during this the
screen remains the same. (3) finally a "Save File" dialog box appears.
The problem is occurring after the user clicks the download link. The
fetch page takes up to five minutes in some cases to copy/stage the
file before redirecting to it for download. During this time the user
might think the app is broken. He or she might click the Download link
again (and again...).
As you can imagine this can be confusing for the user, and this is
definitely not what I want!!! As part of my solution I want to avoid
moving the downloads directory within the website file structure.
How would you guys go about doing this? What can I do to improve on
the design?
TIA,
JP
.
- References:
- Question About Design Strategy
- From: Joey
- Question About Design Strategy
- Prev by Date: Re: ASP.NET sites with built-in max session count governors?
- Next by Date: Re: Application_Start
- Previous by thread: Re: Question About Design Strategy
- Next by thread: Persisting ASP.NET 2.0 Treeview Controls' State within a Master Page
- Index(es):
Relevant Pages
|
Loading