So I read up on this method called PRG as a way of addressing the form double-submit issue. However, I have yet to find a descent implementation of the Summary Page / Success Message displayed to the user. The only way I can think of is storing a session variable, but I don't want it to persist on multiple refreshes. It should show the message/summary once, and be done. Furthermore, it would be ideal if the user could not return to the previously submitted page.
Here is my PRG Code:
Protected Sub InsertRequest() Handles wizard.FinishButtonClick
Using connection As New SqlConnection(connectionStr)
Dim insertQuery As New SqlCommand("spInsertRequest", connection)
insertQuery.CommandType = CommandType.StoredProcedure
'1 - SETUP SQL PARAMETERS (omitted for brevity)
'2 - POST (inserts record into DB)
Try
connection.Open()
insertQuery.ExecuteNonQuery()
connection.Close()
Catch ex As Exception
Logger.WriteToErrorLog(Me, ex.Source, ex.Message, ex.StackTrace)
End Try
'3 - REDIRECT (to the same page and...)
Try
Dim urlRedirect As String = If(IsNothing(Request.Url), "", IO.Path.GetFileName(Request.Url.AbsolutePath)) 'Gets the filename of the current page.
If Not String.IsNullOrEmpty(urlRedirect) Then
Session.Add("referrerPage", urlRedirect) 'Used for identifying when the page is being redirected back to itself.
PageExt.AddParam(urlRedirect, "id", recID.ToString)
Response.Redirect(urlRedirect)
End If
Catch ex As Exception
Logger.WriteToErrorLog(Me, ex.Source, ex.Message, ex.StackTrace)
End Try
End Sub
'4 - GET (Display 'Success' message/summary here)
The question is, how to display this message on the redirect which directly results from the submit, and preferably not for any further refreshes? Or just simply display the message regardless of refreshes, whatever is easiest and makes the most sense. Thanks ;)