Search code examples
c#asp.net-mvccontent-disposition

asp.net-mvc save excel file to specific location


I have the following code that downloads a file to the client's machine and it works great. However, I also need to ask the user where they want to save the file before the download begins.

Is this something I do in the action method (someone in the below code) or is this an option the client has to set on his/her browser and independent of what my code does?

System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;

response.ClearContent();
response.Clear();
response.ContentType = "text/plain";
response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ";");
response.TransmitFile(filePath + fileName);
response.Flush();

response.End();

Solution

  • Yes, "this an option the client has to set on his/her browser and independent of what my code does".