protected void AnswerVote_OnClick(object sender, EventArgs e) { string username; var logginedUser = HttpContext.Current.User.Identity; var vote = (LinkButton)sender; var answerId = int.Parse(vote.CommandArgument); using (var control = new AnswerController()) { username = control.GetAnswerAutherEmail(answerId); } if (logginedUser.IsAuthenticated) // only logedin users can vote to answers { if (logginedUser.Name != username) // nobody can't vote his/her answer { using (var control = new AnswerController()) { control.ManageVote( vote.ID.ToLower().Contains("up") ? AnswerController.VoteType.Up : AnswerController.VoteType.Down, answerId); } } else { ErrorMessage.InnerText = "You can not vote yourself."; ErrorDiv.Visible = true; } AnswersList.DataBind(); } else { var currentUrl = HttpUtility.UrlEncode(Request.Url.PathAndQuery); Response.Redirect($"~/Login.aspx?ReturnUrl={currentUrl}"); } }