On our server we are hosting 10+ websites under the same domain using virtual directory. Now, among them file download function is working in all websites except 2. I have checked everything with the following function but still it's not working.
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlPathEncode(strFileName));
HttpContext.Current.Response.TransmitFile(fileDirectory + @"\" + fileName);
HttpContext.Current.Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
Note that I have also tried to set code for Content-Length, clear response cache but nothing worked. In fact, I have also compared request header of working and non-working website page, but they were also same. Note that the file download works when I use the same code in ashx page! I am 99.99% sure that this must a problem with something other than coding as I didn't find any issue with other websites.
If someone can focus on this than it would be greatly appreciated! Otherwise I would have no choice to apply alternative solutions.
Thanks in advance