1

2 days I've been trying to get my head around this, but no joy.

I have a simple form that posts to a controller action. The form posts, but it doesn't appear to go through the controller action routine as no validation or form field binding occurs - on the dev environment, the fields are populated from the request (I assume by the helper) and validation summary is displayed.

Html

<form method="post" action="/Contact">...fields and submit...</form>

Controller

[HttpPost]
public ActionResult Contact(ContactModel model)
{
     View(model);
}

When I refresh the page after a post back, I don't get asked to re-post the values which makes me think something somewhere is causing a redirect but this doesn't happen in the dev env.

Anyone have any bright ideas? The error logger doesn't seem to report any 500's behind the scenes so nothing there to help.

tereško
  • 58,060
  • 25
  • 98
  • 150
Phil Cooper
  • 3,083
  • 39
  • 63
  • focus on the differences between dev machine and actual web server. .NET framework setup, IIS config, web,config, MVC components, database connection properties and availability etc... – Davide Piras Aug 31 '11 at 20:45
  • One place to start would be checking the HTTP logs with Fiddler or something. If a redirect is happening or if the original request was simply a GET request, you'd see it there. – RandomEngy Aug 31 '11 at 20:46
  • Thanks, good point, should have done that sooner - fiddler it is... I'll see what that throws up if anything. – Phil Cooper Aug 31 '11 at 20:51
  • In fiddler, I seem to be getting a 302 response which then redirects to the same page - any ideas why this would be happening? I'll check google now. – Phil Cooper Aug 31 '11 at 20:57
  • I couldn't submit an answer but it appears it's the missing slash at the end http://stackoverflow.com/questions/2137091/asp-net-mvc-strange-post-behavior - grrrr sad/happy/tired etc – Phil Cooper Aug 31 '11 at 21:01

1 Answers1

3

This was all due to missing / (slash) at the end... The good lord above only knows why.

Updated to include code

<form method="post" action="/Contact/">...fields and submit...</form>

Note the slash at the end of the action attribute.

Phil Cooper
  • 3,083
  • 39
  • 63