B
bryanp10
I have a web application where the admin wants to be able to upload
arbitrary files on an admin page... and then have them accessible for
certain users. Easy enough eh?
The difficulty I'm having is serving up these files in a secure AND
browser-friendly way. I'm using Form authentication. I can't just
drop them in a website directory and show links to the files, because
then anyone could get at a file whose extension is not explicitly
protected by ASP.NET.
So... the option I came up with was to write a proxy page which just
uses Response.WriteFile() after some security checks. Well, that
works fine, but then the URL ends up being something like:
http://mysite.com/getfile?filename=file.doc
...and then of course the browser just dumps the raw bytes of the file,
it doesn't know that this is a .doc file its receiving like if the URL
had been http://mysidte.com/files/file.doc.
Any way to fix this? Do I send down a MIME-type header? If so, where
do I get that? Because the admin could upload any sort of document...
all I have is the file name, more or less. Is there any way to tell
IIS to handle ALL file types for a particular directory? That way
Forms authentication could protect everything?
Any suggestsions greatly appreciated.
arbitrary files on an admin page... and then have them accessible for
certain users. Easy enough eh?
The difficulty I'm having is serving up these files in a secure AND
browser-friendly way. I'm using Form authentication. I can't just
drop them in a website directory and show links to the files, because
then anyone could get at a file whose extension is not explicitly
protected by ASP.NET.
So... the option I came up with was to write a proxy page which just
uses Response.WriteFile() after some security checks. Well, that
works fine, but then the URL ends up being something like:
http://mysite.com/getfile?filename=file.doc
...and then of course the browser just dumps the raw bytes of the file,
it doesn't know that this is a .doc file its receiving like if the URL
had been http://mysidte.com/files/file.doc.
Any way to fix this? Do I send down a MIME-type header? If so, where
do I get that? Because the admin could upload any sort of document...
all I have is the file name, more or less. Is there any way to tell
IIS to handle ALL file types for a particular directory? That way
Forms authentication could protect everything?
Any suggestsions greatly appreciated.