I’m using ASP.NET MVC for creating a blog and whenever user post a comment the form is posted to the url /Post/AddComment but after successfully saving to database I want to redirect the user back to the post where they added comment for ex. http://myblog/archive/2010/11/post.aspx. How I can do that?
Share
You can probably get the URL referrer on the AddComment Action then redirect to that.
e.g.
Alternatively you could pass about a
ReturnUrlin the query string an access this. So if you are clicking a button or a link on the blog post page to add a comment, you could addreturnurl=@Request.UrlThis would then allow you to access this on the POST ActionResult.