English 中文(简体)
i 当从我的网站下载文件时,包括电网和电网一栏,则下载纽吨
原标题:when i download file from my website which contains grid and in one of the column of grid there is download button

I have page called filedownload.aspx , it contains grid and in grid they are three columns and in one of the column there is button which says Download , when user clicks on that button it picks file id and gives the download box to user with three options Open save and cancel .

Now the problem is that when user clicks on the download button in grid it gives this ERROR: INTERNET EXPLORER CANNOT DOWNLOAD FILEDOWNLOAD.ASPX FROM ABC.XYZ.COM (MY URL EXAMPLE) INTERNET EXPLORER WAS NOT ABLE TO OPEN THIS SITE .THE REQUEST SITE IS EITHER UNAVAILABLE OR CANNOT BE FOUND .

一、导 言

页: 1

CAN ANY HELP ME ON THIS ?

我的《手法》:

protected void gdvfiledownload_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Download") { int indexfile = Convert.ToInt32(e.CommandArgument.ToString()); GridViewRow row = gdvfiledownload.Rows[indexfile]; string fileuserid = Ldapinfo.getName(Page.User.Identity.Name); string batchfilename = Convert.ToString(row.Cells[0].Text.ToString()); //string requestedby = Convert.ToString(row.Cells[3].Text.ToString());

            SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString.ToString());
            cn.Open();
            con = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring "].ConnectionString.ToString());
            con.Open();
            DataSet ds = new DataSet();
            //SqlDataAdapter da = new SqlDataAdapter("sp_Insert_CAV2_File", cn);
            SqlCommand sqlCommand = new SqlCommand("sp_proc ", cn);
            sqlCommand.CommandType = CommandType.StoredProcedure;
            sqlCommand.Parameters.AddWithValue("@batch_name", batchfilename);
            sqlCommand.Parameters.AddWithValue("@curr_user", fileuserid);
            SqlDataAdapter da = new SqlDataAdapter(sqlCommand);
            da.Fill(ds);
            StringBuilder  strFD = new StringBuilder();
            for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
            {
                for (int j = 0; j <= ds.Tables[0].Columns.Count - 1; j++)
                {
                    strFD.Append(ds.Tables[0].Rows[i][j].ToString());
                    strFD.Append(" ");
                }
                strFD.AppendLine();
            }

            Response.Clear();
            Response.AddHeader("content-disposition", "attachment;filename=Notepad.txt");
            Response.Charset = "";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = "application/vnd.text";
            System.IO.StringWriter stringWrite = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

            Response.Write(strFD.ToString());
            Response.End();
            cn.Close();
            con.Close();
            cn.Dispose();
            con.Dispose();
        }
    }
    catch (Exception ex)
    {
        lblfilemess.Text = ex.Message.ToString();
    }
}

THANKS, SMARTDEV

问题回答

由于研究很少,我发现两个原因:

(1) 如果在互联网探索者中选择使用IE 6.0 SP1的“不节省加密页到软盘”检查箱,便会出现这一问题。

2) 原因也可能是已知的IIS 6问题。 探讨这些步骤,看它们是否解决问题:

  • Open IIS Admin
  • View the properties for the website
  • Click the HTTP Headers Tab
  • Uncheck the Enable Content Expiration checkbox.

Sources:
http://support.microsoft.com/kb/812935
http://www.alagad.com/blog/post.cfm/error-internet-explorer-cannot-download-filename-from-webserver





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签