I built an app in IronSpeed Designer that works fine when I am just
looking at it using localhost. It's a table that has columns, one of
which is a button. When you click on the button, it looks in the db
for a file that you have uploaded, and downloads the file for viewing.
Everything is working fine when I am on the machine that is hosting it and I look at it using localhost.
It
even looks fine when I have it inside an IFrame. I can do all of the
functionality except the downloading. The event code is in the clicked
event of the button. As I said, it works fine when I am outside the
IFrame.
Any ideas? This is pretty much it as far as what I have to do before I deploy this thing.
public override void Initial_Click(Object sender, EventArgs args)
{
try
{
DbUtils.StartTransaction();
// Get the record.
LegalContractSubmitRecord rec;
rec = this.GetRecord();
if (!(rec == null))
{
this.Page.Response.Write("Inside rec !=null");
// Get the name of the attachment.
string filename = rec.initialFileName;
byte[] contents = rec.initialFile;
// Store the contents of attachment temporarily in a file.
// Delete the temporary file if it exists already.
if (System.IO.File.Exists(filename))
{
System.IO.File.Delete(filename);
}
// Create the temporary file and store contents.
System.IO.FileStream fs;
fs = new System.IO.FileStream(filename, System.IO.FileMode.CreateNew);
System.IO.BinaryWriter bw;
bw = new System.IO.BinaryWriter(fs);
bw.Write(contents);
bw.Flush();
bw.Close();
fs.Close();
// Set up download parameters.
this.Page.Response.ContentType = "APPLICATION/OCTET-STREAM";
string disHeader;
disHeader = "Attachment; Filename=\"" + filename + "\"";
this.Page.Response.AppendHeader("Content-Disposition", disHeader);
System.IO.FileInfo fileToDownload;
fileToDownload = new System.IO.FileInfo(filename);
this.Page.Response.Flush();
this.Page.Response.WriteFile(fileToDownload.FullName);
this.Page.Response.End();
}
}
catch (Exception ex)
{
DbUtils.RollBackTransaction();
// Report the error message to the user.
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "UNIQUE_SCRIPTKEY", "There is no file loaded. Edit the record and upload a file.");
}
finally
{
DbUtils.EndTransaction();
}
}