Hey all,
Having an odd problems with ASP MVC deployed on IIS6 (Windows 2003). I've simplified the controller code to the below;
<AcceptVerbs(HttpVerbs.Get)> _
Public Function CloseBatches() As ActionResult
ViewData("Title") = "Close Batches"
ViewData("Message") = Session("Message")
Return View()
End Function
<AcceptVerbs(HttpVerbs.Post)> _
Public Function CloseBatches(ByVal RequestId As String) As ActionResult
Session("Message") = "Yadda yadda blah"
Return RedirectToAction("CloseBatches")
End Function
The controller did originally do more, of course, but stripped it to this to try to troubleshoot. The page has the basic ViewPage html (master page reference, etc) and then;
<p><%=ViewData("Message")%></p>
<%Using Html.BeginForm("CloseBatches", "Home", New With {.RequestId = "Close"})%>
<input type="submit" id="Close" value="Close"/>
<%End Using%>
As you can see I'm trying to go with the Post-Redirect-Display pattern which seems to be the way to go at the moment. The trouble is the when you click the button the message doesn't appear, no matter how many times you click the button. However, if you do a refresh/F5 the text does appear - then refresh again and it disappears - refresh again and it appears - repeat!
I've had breakpoints on both controller functions and it hits them at the correct points, I've stepped through the code and no errors are happening so the ViewData should be populated, but the page just doesn't always show it!
Tested with IE7 and FF3 - the latter seems a bit more intermittent in that it does occasionally work!
Any ideas? Something obvious I'm missing? Could some weird caching be going on?
Thanks.