I am using a link button to down load a file from the server.
Its is working fine when i am using the full path to the page.
the download link is on the default page.
ie http://mydomain.com/default.aspx
but not working when using http://mydomain.com/
and offcourse it is workign in local host not on the server.
the code i am using is
try
{
// System.String filename = this.ViewState["ImageName"].ToString();
string fileName = "filename.pdf";
// set the http content type to "APPLICATION/OCTET-STREAM
Response.ContentType = "APPLICATION/OCTET-STREAM";
// initialize the http content-disposition header to
// indicate a file attachment with the default filename
// "myFile.txt"
System.String disHeader = "Attachment; Filename=\"" + fileName +
"\"";
Response.AppendHeader("Content-Disposition", disHeader);
// transfer the file byte-by-byte to the response object
System.IO.FileInfo fileToDownload = new
System.IO.FileInfo(Server.MapPath("~/UserUploads/") + fileName);
Response.Flush();
Response.WriteFile(fileToDownload.FullName);
}
catch (System.Exception ex)
// file IO errors
{
//SupportClass.WriteStackTrace(ex, Console.Error);
throw ex;
}
}
please help me to resolve this
thanks in advance
Shibin
try this
Check this for more details