Forcing ASP.NET processing of an arbitrary file

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: MWells (outbound__at_sygnal.com)
Date: 01/08/05


Date: Sat, 8 Jan 2005 15:31:27 +1300

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



Relevant Pages

  • Re: Forcing ASP.NET processing of an arbitrary file
    ... IIS doesn't get a chance to handle the file the way it normally ... > physical file stream I'm returning. ... > were a regular request. ... but it's a hack and prevents me from using third-party HttpHandlers ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HTTP 400 - Bad Request
    ... Windows Server 2003 comes with Network Monitor, ... none of those settings have ANYTHING to do with a 400 Bad Request. ... and IIS never bothered to execute it. ...
    (microsoft.public.inetserver.iis)
  • Granting the ASPNET Account access to the network
    ... but I'm having a problem accessing aspx files that reside on the network. ... Network Service on IIS 6) that is used if the application is not ... IUSR_MACHINENAME) or the authenticated request user. ...
    (microsoft.public.windowsxp.security_admin)
  • Re: Integrated windows security HTTP500 error
    ... different websites on IIS which have different configure, ... The difference must be in how IIS treats a request coming from a browser ... inside the network or from a browser outside the network. ... accessing the website from outside the network, using a VPN connection, ...
    (microsoft.public.inetserver.iis.security)
  • Re: Page Cannot Be Displayed Errors
    ... In WFetch, for Advanced Request, change to "Add Headers" and write: ... > directly on the web server, ... >>> Where can I get the IIS 6.0 Resource Kit, and how do I use WFetch? ...
    (microsoft.public.inetserver.iis)