Uploading/Downloading files with protected extensions

  • Thread starter Thread starter Garett Rogers
  • Start date Start date
G

Garett Rogers

I am creating a document manager for our intranet in VB.NET and I have
stumbled across a problem that I cant seem to find a solution for.

Everything is working as planned:
1) upload a file from webform
2) saves it in a folder outside the current application
3) you can download the file once it's uploaded

The problem happens when a file is uploaded with an extension that's
protected.. such as .vb, .config, .cs, etc. etc.
The server naturally wont let you download these files due to security
reasons..

The ideal solution would be to allow these types of files to be read from
only the directory that i'm storing these files in.

How would you suppose I do this?

Thanks,
Garett
 
Hi Garett,

Don't know wheter it works but try to modify the content-type.
Here's a code snippet

Response.ClearContent();
Response.ClearHeaders();
Response.Buffer = true;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" +
szFileName);
Response.WriteFile(szFileName);


HTH,
Stefano Mostarda MCP,
Rome Italy
 
Back
Top