I have a blog page with comments. Any user (registered or not) can see the form at the bottom of the page to post a comment. When a user enters a comment, and it is not authorized, the user is redirected to the login / registration page. After logging in, the user is redirected back to the action, but the POST data containing the comment body is lost.
I use the Authorize MVC ASP.NET attribute to request authorization for some actions:
[AcceptVerbs(HttpVerbs.Post), Authorize]
public ActionResult Create(int blogPostID, string commentBody) {
var comment = new Comment {
Body = commentBody,
BlogPostID = blogPostID,
UserName = User.Identity.Name
}
// persist the comment and redirect to a blog post page with recently added comment
}
How do you solve this problem?
Creating a user login before displaying the comment form is a bad idea, I think.
Thank.
Zelid source