Thanks for the advice, guys! I've got the two smartest guys in the room giving me advice, so it must be a unique problem.
I've been thinking along the same lines you guys suggested, only not as flushed out in strategy. My thought was to make all my links to something like /File.aspx?FileID=xxxxx and then from there, send down a mime type and then stream the bytes over the wire. I haven't figured out yet how this is going to work, but I'm thinking if I could get that to redirect to the 404 page, then it should be able to reap the query string.
But then I thought of a problem with this scheme. It's not only bad links I want to trap, some of the files will exist. And if somebody requests http://mysite.com/volunteer_stipends.pdf, if the file exists, IIS will send the file. That one, in particular, only a very few logged in users should have access to. Another reason to use ID #s instead of file names in my hyperlinks would be to add a little bit of security, but counting on people not to know the URLs seems to be a really bad security scheme.
So is there a way ( with C# in ASP.NET 2 ) to catch the event before someone downloads a file that's there? I'd like to look at who they are, and then decide whether they're authorized, and then return either the bytes in the file, or a redirect to my not authorized page.
|