-1

当我上传文件时。大于 12mb 的文件未上传且会话在执行时过期

protected void populateCategoryList()
{
    try
    {
        string strCon = ConfigurationManager.ConnectionStrings["mcqConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(strCon);

        SqlCommand command = new SqlCommand("usp_MCQ_GetCategories", conn);
        command.CommandType = CommandType.StoredProcedure;
        command.Parameters.Add(new SqlParameter("@type", "Video"));
        conn.Open();
        SqlDataAdapter adapter = new SqlDataAdapter(command);
        conn.Close();

        DataSet ds = new DataSet();
        adapter.Fill(ds, "CategoryList");

        lbCategory.Controls.Clear();
        if (ds.Tables.Count > 0)
        {
            DataTable result = ds.Tables[0];
            if (result.Rows.Count > 0)
            {
                for (int i = 0; i < result.Rows.Count; i++)
                {
                    DataRow odrMain = result.Rows[i];
                    if (odrMain["parent_cat"].ToString().Trim() == "0" || odrMain["parent_cat"].ToString().Trim() == "")
                    {
                        lbCategory.Items.Add(new ListItem(odrMain["name"].ToString(), odrMain["id"].ToString()));

                        for (int k = 0; k < result.Rows.Count; k++)
                        {
                            DataRow odr = result.Rows[k];
                            if (odr["parent_cat"].ToString().Trim() == odrMain["id"].ToString().Trim())
                            {
                                lbCategory.Items.Add(new ListItem("\xA0\xA0\xA0\xA0" + odr["name"].ToString(), odr["id"].ToString()));
                            }
                        }
                    }
                }
            }
        }
    }
    catch (Exception ex)
    {
        //exception handling
    }
}

protected void createMedia_Click(object sender, EventArgs e)
{
    string rootPath = Server.MapPath("~/videos/");
    if (FileUploadVideos.FileName.Contains(".mp4") || FileUploadVideos.FileName.Contains(".MP4") || FileUploadVideos.FileName.Contains(".mp3") || FileUploadVideos.FileName.Contains(".MP3"))
    {
        string selectedCategories = "";
        for (int i = 0; i < lbCategory.Items.Count; i++)
        {
            if (lbCategory.Items[i].Selected)
            {
                selectedCategories += lbCategory.Items[i].Value + ",";
            }
        }
        int[] status = new int[2];
        status = SQLHelper.createVideo(tbTitle.Text.Trim(), selectedCategories, Path.GetExtension(FileUploadVideos.FileName), Path.GetExtension(FileUploadPoster.FileName));

        if (status[0] == 1)
        {
            ErrorMessage.Text = "Media added sucessfully. Use above form to add another Video/Podcast";
            FileUploadVideos.SaveAs(rootPath + status[1].ToString() + Path.GetExtension(FileUploadVideos.FileName));
            if (FileUploadPoster.HasFile)
            {
                FileUploadPoster.SaveAs(rootPath + status[1].ToString() + Path.GetExtension(FileUploadPoster.FileName));
            }

            emptyFields();
        }
        else if (status[0] == -1)
            ErrorMessage.Text = "Media already exists. Please try some other Title";
        else
            ErrorMessage.Text = "Some error occured. Please try again. If problem persists conatct your administrator";
    }
    else
    {
        ErrorMessage.Text = "Only MP4 media is allowed to upload.";
    }
}
4

2 回答 2

1

你确定你在 web.config 中的设置没问题吗?maxrequestlength 是以 KB 为单位的文件大小,执行超时是它超时之前的时间,以秒为单位。

<httpRuntime  maxRequestLength="90240" executionTimeout="420"/>
于 2013-08-06T10:03:22.753 回答
1

请参考此链接

尝试调整 web.config 中的 maxRequestLength。

  <system.web>
    <httpRuntime maxRequestLength="[number in KB]" />
  </system.web>
于 2013-08-06T10:04:25.043 回答