473,597 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forcing ASP.NET processing of an arbitrary file

I have a simple project server which shares files from within our network.
The ASP.NET front end uses a database to authenticate users, and then based
on their permissions, reaches across the network to various project folders
and enumerates the files within. When clicked on, the file is retrieved and
streamed back across the network to the webserver and then back to the
requestor.

All of this works great; however, since the original call is to an ASPX
page, and the result is a data file (e.g. a word document, a tiff,
whatever), IIS doesn't get a chance to handle the file the way it normally
would.

The specific problem I'm facing is that I have certain HttpHandlers that
specially render certain document types. For example, I might have a
handler registered for the ".foo" document type. Because the actual IIS
request was formed like;

http://mysite/getfile.aspx?File=test.foo

IIS hands this off to the ASPX handler, which then goes and gets test.foo
and returns it.

How can I force IIS to also process the .foo file using the registered
HttpHander? I'm exploring three obvious approaches; and looking for advice
on the best decision and most straightfoward approach.

(1) Use an HttpModule. I've never worked with these; and I'm unfamiliar
with the capabilities, but investigations so far are leading me in this
direction as the "best long term choice".

(2) Find some way to get IIS to execute the HttpHandler processing on the
physical file stream I'm returning. I.e. I open a stream to the file data,
get the filename, and tell IIS to process and return this file as though it
were a regular request. I'm guessing this exists somewhere in the Server or
Request object models, but I haven't discovered anything obvious yet.

(3) Move all my custom HttpHandler code into my file requestor. This would
work, but it's a hack and prevents me from using third-party HttpHandlers in
the same way.

Thanks for any advice.

--Mwells

Nov 19 '05 #1
2 1295

May be another solution is to send content of your file as binary data and
specify the true content type in the HTTP Header like this:
Response.Conten tType = "applicatio n/ms-word";
Response.AddHea der("Content-Disposition", "attachment;fil ename=word.doc" );

See more in http://www.ondotnet.com/pub/a/dotnet...04/01/asp.html
or http://www.eggheadcafe.com/articles/20011006.asp

Lionel.
"MWells" <outbound__at_s ygnal.com> a écrit dans le message de news:
ey************* *@tk2msftngp13. phx.gbl...
I have a simple project server which shares files from within our network.
The ASP.NET front end uses a database to authenticate users, and then
based
on their permissions, reaches across the network to various project
folders
and enumerates the files within. When clicked on, the file is retrieved
and
streamed back across the network to the webserver and then back to the
requestor.

All of this works great; however, since the original call is to an ASPX
page, and the result is a data file (e.g. a word document, a tiff,
whatever), IIS doesn't get a chance to handle the file the way it normally
would.

The specific problem I'm facing is that I have certain HttpHandlers that
specially render certain document types. For example, I might have a
handler registered for the ".foo" document type. Because the actual IIS
request was formed like;

http://mysite/getfile.aspx?File=test.foo

IIS hands this off to the ASPX handler, which then goes and gets test.foo
and returns it.

How can I force IIS to also process the .foo file using the registered
HttpHander? I'm exploring three obvious approaches; and looking for
advice
on the best decision and most straightfoward approach.

(1) Use an HttpModule. I've never worked with these; and I'm unfamiliar
with the capabilities, but investigations so far are leading me in this
direction as the "best long term choice".

(2) Find some way to get IIS to execute the HttpHandler processing on the
physical file stream I'm returning. I.e. I open a stream to the file
data,
get the filename, and tell IIS to process and return this file as though
it
were a regular request. I'm guessing this exists somewhere in the Server
or
Request object models, but I haven't discovered anything obvious yet.

(3) Move all my custom HttpHandler code into my file requestor. This
would
work, but it's a hack and prevents me from using third-party HttpHandlers
in
the same way.

Thanks for any advice.

--Mwells

Nov 19 '05 #2
I'm actually doing that already, which keeps the client happy. If I hit a
Uri like;

http://mysite.com/getfile.aspx?FileID=123

And it pulls an Excel file from the database, the type and name are
appropriately specified so that the client recognizes it properly as an
Excel file.

Unfortunately this still excludes HttpHandlers from ASP.NET's processing
chain. If I have an HttpHandler installed that (for example) renders the
contents of the Excel file as HTML, that handler never gets called in the
execution chain.

Originally I thought it was due to the fact that .NET needs the Uri file
extension in order to associate the HttpHandler, so I've rewritten the
access Uri format using an HttpModule.

Now, I can request a file like...

http://mysite.com/files/data.xls

And the file data.xls is actually pulled from a database, mime-typed, and
returned to the client. All works well but the HttpHandler is still
excluded from the processing chain, and my handlers are never run.

I'm going off to think about this for a bit and then I'll fire off a new
post.

"Lionel LASKE" <ll****@c2s.f r> wrote in message
news:uH******** *****@TK2MSFTNG P11.phx.gbl...

May be another solution is to send content of your file as binary data and
specify the true content type in the HTTP Header like this:
Response.Conten tType = "applicatio n/ms-word";
Response.AddHea der("Content-Disposition", "attachment;fil ename=word.doc" );

See more in http://www.ondotnet.com/pub/a/dotnet...04/01/asp.html
or http://www.eggheadcafe.com/articles/20011006.asp

Lionel.

Nov 19 '05 #3

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

Similar topics

3
1767
by: D. Alvarado | last post by:
Hello, I have a page that generates a text file (but writes the file with the ".csv" extension) and then I redirect the user so he can save the file header("Location: $my_csv_file"); However, the file appears as text in the browser and I would prefer that the gray "Download this file" box pop up. How could I pull this off, or is this really more dependent on client browser settings?
4
2286
by: Dan Rawson | last post by:
Is there any way to force getopt to process one option first?? I'd like to be able to pass in the name of a configuration file for my application, then have the remaining command-line parameters over-ride the configuration file if they are present. For the moment, I'm restricted to 2.2 versions. TIA . . . . Dan
1
2908
by: DJTB | last post by:
zodb-dev@zope.org] Hi, I'm having problems storing large amounts of objects in a ZODB. After committing changes to the database, elements are not cleared from memory. Since the number of objects I'd like to store in the ZODB is too large to fit in RAM, my program gets killed with signal 11 or signal 9... Below a minimal working (or actually: it doesn't work because of memory
6
1872
by: S P Arif Sahari Wibowo | last post by:
Hi! I am thinking to have a client-side script doing processing on file downloading, basically the script will process a downloaded file from the server before it received by the user. For example, the weboage will have a link to download file A, but the one stored in the server is not exactly file A, but some transformation of it. If the user click the link, it activate the script which will actually load the file from the server,...
1
1574
by: Mark Rae | last post by:
Hi, I have to process a very "wide" CSV file. Basically, the file does not appear correctly in Notepad, WordPad etc because each line is 414 characters wide. Ordinarily, I would have read the file into a StreamReader and processed each line in turn e.g. objSR = new StreamReader(strFileSpec); while ((strLineIn = objSR.ReadLine()) != null)
6
4974
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a PDF. It works fine so far....
0
1428
by: Conrad | last post by:
Greetings, For user actions on a wxWidget that trigger multiple events for that wxWidget, is the order those events are processed in undefined, and therefore arbitrary from one platform (ie Windows) to the next (ie Linux)? Specifically, I have a convience aggregate class that combines a wxStaticText with a wxComboBox, as I often need those two at the same time. The aggregate catches events from the wxComboBox
2
1432
by: kmsuzuki | last post by:
I have a Windows Server 2003 + IIS6 with both .Net 1.1 and 2.0 installed. In the past, I've had no problems using the ASP.NET tab in the IIS Manager to specify which framework version a given application should use. I created a .Net 1.1 VB.NET web service in Visual Studio.NET 2003. I built it and then copied it to the web server described above, specifying in IIS Manager that it should use the 1.1. framework. When I try to run the...
1
3427
by: Xah Lee | last post by:
Text Processing with Emacs Lisp Xah Lee, 2007-10-29 This page gives a outline of how to use emacs lisp to do text processing, using a specific real-world problem as example. If you don't know elisp, first take a gander at Emacs Lisp Basics. HTML version with links and colors is at: http://xahlee.org/emacs/elisp_text_processing.html
0
7970
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7887
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8274
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8259
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6695
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3886
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2404
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.