Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please Guys How do I make a comment to return me to the Id of the comment made. If i make a comment, it takes me back to the Id of the Post.

Meaning that if a topic has 10 pages and i make a comment, instead of it taking me to the last page where the comment Id is, it takes me back to page 1 where the Post Id is.

How do i fix this???

This is what i have:

C#
var myquote = new ModQuote
                {
                    UserId = WebSecurity.GetUserId(user),
                    PostId = model.PostId,
                    Comment = model.Comment,
                    ReplyId = model.ReplyId,
                    ProfileId = model.ProfileId,
                    By = User.Identity.Name,
                    File = model.File
                };
                //var last = db.MyModQuote.Where(a => a.PostId == id).AsEnumerable().LastOrDefault();
                //if (last != null)
                //{
                //    var find = db.Posts.Find(last.PostId);
                //}
                
                db.MyModQuote.Add(myquote);
                db.SaveChanges();
                return RedirectToAction("topics", new { id = id });
            }


            return View(model);


What I have tried:

I have tried this:

db.MyModQuote.Add(myquote);
db.SaveChanges();
return RedirectToAction("topics", new { id = commentId});
}
Posted
Comments
[no name] 14-Mar-16 2:39am    
You are returning RedirectToAction(..) before return View(). So it is redirecting to topics action with post id.
Member 12139499 14-Mar-16 3:15am    
i have tried return RedirectToAction("topics", new { id = commentId}); but it gives an error message because it is carrying only the commentId

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