Reputation: 24789
My form isn't always submitted when I hit the submit button.
On my form I have one submit button. When I first hit the button, the form will submit. But when there's a validation error, the error is shown. But when I fix that error and press the submit button again, the form is not submitted. This will happen if you work with 'normal' speed; if you do everything very slow, then the form will submit.
In the 'normal speed' mode I see in FireBug that there's a request to the server, but my breakpoint in the code is never hit! So I keep on the same page and nothing happens. When I click multiple times (5-10) or I wait a few seconds and then click the submit button, the submit will reach my code.
I am using MVC4 with the .NET 4.5 framework.
I hope someone can help me with this..
EDIT:
This is the code I am talking about.
My html (with razor) code:
<div id="content" class="boxBorder">
<form method="post" action="/Import/ProcessStep" @(Model.UploadFiles ? "enctype=multipart/form-data" : "") id="wizardForm">
<table id="detailsTable" width="550" cellspacing="0" border="0">
<thead>
<tr>
<th class="first">Importwizard
</th>
</tr>
<tr>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<td></td>
</tr>
</tfoot>
<tbody>
<tr>
<td> </td>
</tr>
<tr>
<td>
<div id="ImportProgressBar">
<ul>
@foreach (var step in Model.StepNames)
{
<li>
<div class="WizardProgressStep">
<img src="@step.Value" class="ProgressStepImage" />
<br />
<span>@step.Key</span>
</div>
</li>
}
</ul>
</div>
<div id="StepTitle">
@Model.StepTitle
<hr />
</div>
<div id="StepContent">
@RenderBody()
</div>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<div id="WizardNavigationBox">
@if (Model.HasPreviousButton)
{
<input type="submit" name="PreviousStep" id="PreviousStep" value="Vorige" class="button icon add" />
}
@if (Model.HasNextButton)
{
<input type="submit" name="NextStep" id="NextStep" value="Volgende" class="button icon add saveButton" />
}
</div>
</td>
</tr>
</tbody>
</table>
</form>
</div>
My controller:
[HttpPost]
public ActionResult ProcessStep(FormCollection formCollection)
{
WebMediator mediator = new WebMediator();
ViewResult newStep;
GenericWizardViewModel viewModel;
if (formCollection["NextStep"] != null)
{
ValidateStep(formCollection);
if (ModelState.IsValid)
{
mediator.ProcessStep(formCollection);
newStep = mediator.GetNextStep();
}
else
{
IWizardStep currentStep = mediator.GetCurrentStep();
viewModel = mediator.CreateViewModel(currentStep);
return this.RazorView(currentStep.StepName, viewModel);
}
}
else
{
newStep = mediator.GetPreviousStep();
}
viewModel = newStep.Model as GenericWizardViewModel;
return this.RazorView(newStep.ViewName, viewModel);
}
Upvotes: 0
Views: 521
Reputation: 24789
We finally figured it out.
All our controllers inherit from a custom BaseController
class. This BaseController
had an trribute with OutputCache
on it with a duration set to 10 seconds. Removing this attribute fixed my problem.
Upvotes: 1