protected void BtnAddArticle_Click(object sender, EventArgs e) { try { if (FlUpldImageUpload.HasFile) { HttpPostedFile postedFile = FlUpldImageUpload.PostedFile; if (postedFile.ContentType.Contains("image") && postedFile.ContentLength < 204800) { byte[] bytes; using (BinaryReader br = new BinaryReader(postedFile.InputStream)) { bytes = br.ReadBytes(postedFile.ContentLength); } List <int> categoryValues = new List <int>(); foreach (ListItem item in LbCategories.Items) { if (item.Selected) { categoryValues.Add(Int32.Parse(item.Value)); } } int writerId = Int32.Parse(DdlDevelopers.SelectedValue); var result = DbManager.AddArticle(TxtbxArticleTitle.Text, bytes, TxtAreaArticleContent.Text, categoryValues, writerId); if (result.Success == true) { Application["Info"] = result.Message; Response.Redirect("default.aspx"); Context.ApplicationInstance.CompleteRequest(); } else { InfoLabel(result.Message); } } else { InfoLabel(Messages.UploadImageError); } } else { InfoLabel(Messages.Error); } } catch (Exception) { InfoLabel(Messages.Error); } }