Posts

Showing posts from January, 2012

MVC3: Redirect Action to HTML Bookmark

I'm currently in the process of writing my next personal project, RustyShark in .Net MVC3. It's a game and films review site, and will hopefully generate a bit of a community. Each review on the website has a comments form at the bottom that readers can use to post their own mini review, or just a simple comment. I'm using unobtrusive client side validation, but (as it should) the validation also occurs on the server side. This means that the user could potentially receive an error message on the comments form after a post-back but not notice it, as they will be redirected to the top of the page, rather than the comments form.

The "read review" page is accessed via the fairly standard route /Reviews/Read/{titleURL}, which means the reviews controller exposes the Read action method. The Read method has a single override which is tagged with the [HttpPost] attribute as follows:

publicclass ReviewsController : Controller { public ActionResult Read(string tit…