FileInfo
fi = new FileInfo(Session["DocName"].ToString());
if
(!fi.Exists)
return;
Response.ClearContent();
Response.ClearHeaders();
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.ContentType = "application/download";
Response.AddHeader("Content-Disposition", "attachment; filename=" + fi.Name);
Response.AddHeader("Content-Length", fi.Length.ToString());
Response.WriteFile(Session["DocName"].ToString());
Response.End();
on your asp page have code thus
Session["DocName"]
= @"c:\blah\blah.xlsx";
string
iframeID = "iframe_contentview";
string
iframe = string.Format("<iframe
id=\"{0}\" src=\"{1}\"
style=\"display:none\"></iframe>", iframeID, "doc.aspx");
ClientScript.RegisterStartupScript(GetType(), iframeID, iframe);
and that's it
presto!
No comments:
Post a Comment