protected void ButtonAddPost_Click(object sender, EventArgs e) { database.StartConnection(); if (FileUploadImage.HasFile) { FileUploadImage.SaveAs("C:/Users/Alex/source/repos/BlogWork/BlogWork/Resources/" + FileUploadImage.FileName); database.AddPost(TextBoxTheme.Text, TextBoxDescription.Text, PostBody.InnerText, "~/Resources/" + FileUploadImage.FileName, FormsAuthentication.Decrypt(Request.Cookies["AuthCookie"].Value).Name); database.LoadPosts(); Response.Redirect("~/WebForms/Default.aspx?CurrentPost=" + database.LastPostIndex()); database.CloseConnection(); } else { database.AddPost(TextBoxTheme.Text, TextBoxDescription.Text, PostBody.InnerText, null, FormsAuthentication.Decrypt(Request.Cookies["AuthCookie"].Value).Name); database.LoadPosts(); Response.Redirect("~/WebForms/Default.aspx?CurrentPost=" + database.LastPostIndex()); database.CloseConnection(); } }