O
Oleg Ogurok
Hi all,
In my ASP.NET application, I have a page that serves files from database to
the clients. Here's the code:
private void Page_Load(object sender, System.EventArgs e)
{
byte[] fileData = GetDataBinary(int fileID);
Response.ContentType = "Application/x-msexcel";
Response.BinaryWrite(fileData);
Response.End();
}
I wonder if there is a simple way to set the ContentType for any type of
file. Since I'm storing the file name in the database as well, I can extract
its extension, e.g. .pdf, .xls, .doc, etc. Is there a method in .NET
framework that maps file extension to the corresponding content type?
Thanks.
-Oleg.
In my ASP.NET application, I have a page that serves files from database to
the clients. Here's the code:
private void Page_Load(object sender, System.EventArgs e)
{
byte[] fileData = GetDataBinary(int fileID);
Response.ContentType = "Application/x-msexcel";
Response.BinaryWrite(fileData);
Response.End();
}
I wonder if there is a simple way to set the ContentType for any type of
file. Since I'm storing the file name in the database as well, I can extract
its extension, e.g. .pdf, .xls, .doc, etc. Is there a method in .NET
framework that maps file extension to the corresponding content type?
Thanks.
-Oleg.