下载任何文件后如何刷新或重新加载页面 [英] How to refresh or reload page after download any file
本文介绍了下载任何文件后如何刷新或重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hii全部,
m使用下面的代码,它工作正常,但是下载文件后我必须重新加载页面,我尝试了很多方法,但是没有用
Hii All,
m using below code and it is working fine but I have to reload page after download the file,I tried lots of method but It didn''t work
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData("File path here");
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=" + ViewState["Cont"].ToString());
//Response.ContentType = "application/octet-stream";
Response.ContentType = MimeType(Path.GetExtension("File name here"));
Response.Buffer = true;
Response.OutputStream.Write(buffer, 0, buffer.Length);
Response.OutputStream.Flush();
Response.End();
//this is function to get file extension
public static string MimeType(string Extension)
{
string mime = "application/octetstream";
if (string.IsNullOrEmpty(Extension))
return mime;
string ext = Extension.ToLower();
Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
if (rk != null && rk.GetValue("Content Type") != null)
mime = rk.GetValue("Content Type").ToString();
return mime;
}
如果有任何解决方案,请分享plz
Thanx
If any one have any solution plz share
Thanx
推荐答案
检查此答案:下载文件后更新页面 [ ^ ]
这篇关于下载任何文件后如何刷新或重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文