我这里只有按了下载按钮后才会出现这个拒绝访问的情况
点击其它控件(没点击下载按钮之前)都运行的蛮正常的
下面是我的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);
}
请大家帮我看看

解决方案 »

  1.   

    try replace withSystem.IO.FileStream fs = System.IO.File.OpenRead( strPhysicalPath );
    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();
      

  2.   


    可以了
    谢谢gOODiDEA(无语)兄