我这里只有按了下载按钮后才会出现这个拒绝访问的情况
点击其它控件(没点击下载按钮之前)都运行的蛮正常的
下面是我的DownLoad按钮中的处理
private void Download_Click(object sender, System.EventArgs e)
{
string strPhysicalPath="";
if(ChooseType.SelectedIndex==0)
strPhysicalPath="E:\\"+Session["username"].ToString()+"\\Removeparameters.x_t";
FileInfo objFileInfo = new FileInfo(strPhysicalPath);
Response.AddHeader("Content-Disposition", "attachment; filename="+objFileInfo.Name);
Response.AddHeader("Content-Length", objFileInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(objFileInfo.FullName);
}
请大家帮我看看
点击其它控件(没点击下载按钮之前)都运行的蛮正常的
下面是我的DownLoad按钮中的处理
private void Download_Click(object sender, System.EventArgs e)
{
string strPhysicalPath="";
if(ChooseType.SelectedIndex==0)
strPhysicalPath="E:\\"+Session["username"].ToString()+"\\Removeparameters.x_t";
FileInfo objFileInfo = new FileInfo(strPhysicalPath);
Response.AddHeader("Content-Disposition", "attachment; filename="+objFileInfo.Name);
Response.AddHeader("Content-Length", objFileInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(objFileInfo.FullName);
}
请大家帮我看看
解决方案 »
- 又升一猩!问个小问题可散技术分!
- 验证码的无刷新原理是什么?
- 求一sql语句!在线等待!
- 关于webConfig的修改问题
- 除了windows Media service流媒体服务器,市面上还有哪些可选的???在Unix下一般用什么样的流媒体服务器???
- ¥¥¥高分100 求chyich 写的“学习Duwamish 7.0笔记”和《项目总结》
- PD15生成报表的问题
- 如何在数据库里,把存储的用逗号分割的词组一个一个的读出来?高手帮忙呀!
- 谁读过NHibernate代码?他是如何实现实体类中非string类型初始化问题的?
- 用DIV+CSS布局的问题
- 有VS.NET,怎样在WIN2K上仅安装.NET?
- 在线等待帮助....谁帮我解给他100分
byte[] FileData = new byte[ fs.Length ];
fs.Read( FileData, 0, ( int ) fs.Length );
Response.Clear();
Response.AddHeader( "Content-Type", "application/zip" );
string FileName = System.Web.HttpUtility.UrlEncode( System.Text.Encoding.UTF8.GetBytes( "test.zip" ) );
Response.AddHeader("Content-Disposition", "inline;filename="+ System.Convert.ToChar(34) + FileName + System.Convert.ToChar(34) );
Response.AddHeader("Content-Length", fs.Length.ToString() );
Response.BinaryWrite( FileData );
fs.Close();
Response.End();
可以了
谢谢gOODiDEA(无语)兄