Hi,
Basically, what I am trying to do is automatically serve a file to a user, so that when the html page reloads, the user is prompted to "save/open the file". However, the file to be served is created by an external DLL, which then writes it to a folder where the ASP website is stored, e.g.:
1) Website in x:\inetpub\ ASP script 'write_file.asp' calls vb dll
3) VB DLL creates file, and writes to x:\inetpub\4) ASP script continues executing, and proceeds to write the following Response headers:
Response.AddHeader "Content-Disposition", "attachment; filename=" & Chr(34) & strFileLocation & Chr(34)
Response.AddHeader "Content-Length", objRM.strFileLength
Response.ContentType = "text/csv"
which serve the file.
5) Some HTML is written to the browser, indicating success in a particually garish neon text.
* objRM is a class of the DLL, that writes out the file
* strFileLocation is supposed to be where the file is stored, I've tried absolute values with Server.MapPath("tmpfiles\") & "report.csv", as well as relative values, like: "/tmpfiles/report.csv" and "\tmpfiles\report.csv" and other attempts with and without the first slash.
Now, IE prompts with a file save box, but proceeds to serve the HTML that is output from the write_file.asp script after the response.addheaders are called. I cannot get it to serve the report.csv that has been generated. I'm not sure if it's a security issue (I've added a virutal directory in the IIS Services Control) or, if I'm just pathing incorrectly.
If anyone could provide exact details on how exactly I'm supposed to accomplish (Headers, security settings etc) this task, I'd be most grateful as I'm pretty new to ASP, and it's a bit different to PHP
Many Thanks
Yum.
Basically, what I am trying to do is automatically serve a file to a user, so that when the html page reloads, the user is prompted to "save/open the file". However, the file to be served is created by an external DLL, which then writes it to a folder where the ASP website is stored, e.g.:
1) Website in x:\inetpub\ ASP script 'write_file.asp' calls vb dll
3) VB DLL creates file, and writes to x:\inetpub\4) ASP script continues executing, and proceeds to write the following Response headers:
Response.AddHeader "Content-Disposition", "attachment; filename=" & Chr(34) & strFileLocation & Chr(34)
Response.AddHeader "Content-Length", objRM.strFileLength
Response.ContentType = "text/csv"
which serve the file.
5) Some HTML is written to the browser, indicating success in a particually garish neon text.
* objRM is a class of the DLL, that writes out the file
* strFileLocation is supposed to be where the file is stored, I've tried absolute values with Server.MapPath("tmpfiles\") & "report.csv", as well as relative values, like: "/tmpfiles/report.csv" and "\tmpfiles\report.csv" and other attempts with and without the first slash.
Now, IE prompts with a file save box, but proceeds to serve the HTML that is output from the write_file.asp script after the response.addheaders are called. I cannot get it to serve the report.csv that has been generated. I'm not sure if it's a security issue (I've added a virutal directory in the IIS Services Control) or, if I'm just pathing incorrectly.
If anyone could provide exact details on how exactly I'm supposed to accomplish (Headers, security settings etc) this task, I'd be most grateful as I'm pretty new to ASP, and it's a bit different to PHP
Many Thanks
Yum.