加MagicAjax后下载保存不显示了????Why???
我在做B/S结构时,做好了下载文件到客户端了,但加了MAGICAJAX后,不能弹出保存路径选择页面,请教:怎么处理MAGICAJAX下的保存???(就是下载- "打开 "? "保存 "?取消?)是不是在IE中什么地方控制????急急急!!!
------解决方案--------------------magicajax本来就对JS支持不好,很容易冲突的,反正我一般只在浏览的页面里用一下这个做无刷 。
------解决方案--------------------magicajax本来就对JS支持不好,很容易冲突的,反正我一般只在浏览的页面里用一下这个做无刷
------------------------------------。
偶支持~!
------解决方案--------------------protected void DownloadFile(string filename)
{
HttpContext context = HttpContext.Current;
string saveFileName = "test.xls";
int intStart = filename.LastIndexOf("\\") + 1;
saveFileName = filename.Substring(intStart, filename.Length - intStart);
System.IO.FileInfo fi = new System.IO.FileInfo(filename);
string fileextname = fi.Extension;
string DEFAULT_CONTENT_TYPE = "application/unknown";
RegistryKey regkey, fileextkey;
string filecontenttype;
try
{
regkey = Registry.ClassesRoot;
fileextkey = regkey.OpenSubKey(fileextname);
filecontenttype = fileextkey.GetValue("Content Type", DEFAULT_CONTENT_TYPE).ToString();
}
catch
{
filecontenttype = DEFAULT_CONTENT_TYPE;
}
//MagicAjax.AjaxCallHelper.Write("window.open('saveAttach.aspx','newwindow', 'height=280, width=400, top=200, left=300, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no');");
HttpResponse _response = context.Response;
_response.Clear();
_response.Charset = "gb2312";
_response.Buffer = true;
this.EnableViewState = false;
_response.ContentEncoding = System.Text.Encoding.Default;
_response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlPathEncode(saveFileName));
//其中Server.UrlPathEncode(saveFileName)可以保证输出的文件名是中文是无乱码
_response.ContentType = filecontenttype;
_response.WriteFile(filename);
_response.Flush();
_response.Close();
_response.End();
}