Click here to Skip to main content
15,905,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
protected void btnUpload_Click(object sender, EventArgs e)
{
using (BinaryReader br = new BinaryReader(FileUpload1.PostedFile.InputStream))
{
byte[] bytes = br.ReadBytes((int)FileUpload1.PostedFile.InputStream.Length);
string strConnString = ConfigurationManager.ConnectionStrings["Crime"].ConnectionString;
using (SqlConnection con = new SqlConnection(strConnString))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "insert into tblFiles(Name, ContentType, Data) values (@Name, @ContentType, @Data)";
cmd.Parameters.AddWithValue("@Names", Path.GetFileName(FileUpload1.PostedFile.FileName));
cmd.Parameters.AddWithValue("@ContentType", "video/mp4");
cmd.Parameters.AddWithValue("@Data", bytes);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
Response.Redirect(Request.Url.AbsoluteUri);
}

I have problem in my above code when try to upload vedio through this code my web page gets expired I don't understand why it's happening please help ........
Posted

1 solution

hello,
There may be a couple of reasons.

1) May be session time is less... try to increase session time

2) May be in DataBase call may the connection timed out. To prevent that one please increase that value

Place this line in your code (above function)

cmd.CommandTimeout = 5000;
 
Share this answer
 
Comments
Rohit kumar6210 6-Mar-14 2:34am    
I have entered above code but problem is still there Please help .............

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900