providing file name in url is like giving the exact path. you can use the following way to achive it.
provide list of download - ables on a page. use user clicks on desirable file you will redirect it to download.aspx page with productid in querystring (download.aspx?pid=5)
at download page use this code under a switch case block with pid as cases.
this example deals with excel sheet and the best points are
1. There will no redirection of aspx page, but file will be downloaded.
2. User will not come to know the path of file from URL
Here's the code is :
FileInfo file = new FileInfo(PathToExcelFile);
if (file.Exists)
{
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
Response.AddHeader("Content-Type", "application/Excel");
Response.ContentType = "application/vnd.xls";
Response.AddHeader("Content-Length", file.Length.ToString());
Response.WriteFile(file.FullName);
Response.End();
}
else
{
Response.Write("This file does not exist.");
}
Dont forget to mark as answer.