Asp.Net 文件输出问题
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Charset = "UTF-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename="+filename );
HttpContext.Current.Response.AddHeader("Content-Length", bt.Length.ToString());
HttpContext.Current.Response.ContentType = conttype;
HttpContext.Current.Response.BinaryWrite(bt);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
上面是一个文件输出的代码
我想实现,如果文件是JPG的就直接在IE里打开了,如果是PDF客户端装有那东西也在IE里找开
如果是EXE之类的文件就直接下载了
可是如果注掉以下代码
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename="+filename );
HttpContext.Current.Response.AddHeader("Content-Length", bt.Length.ToString());
文件可以在JPG,PDF可以在IE里打开可是EXE.RAR文件就不会出现下载的窗口,。ZIP文件到是可以下载
请问要如何才来实现这样的效果了