#5260: Fixed the issue where form validation result gets output cached.

Fixes #5260
This commit is contained in:
Sipke Schoorstra
2015-07-04 13:01:17 +02:00
parent c8f2c27311
commit 6bce34f379

View File

@@ -6,6 +6,7 @@ using Orchard.DynamicForms.Services;
using Orchard.Layouts.Services;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Services;
using Orchard.Tokens;
using Orchard.UI.Notify;
using IController = Orchard.DynamicForms.Services.IController;
@@ -16,17 +17,20 @@ namespace Orchard.DynamicForms.Controllers {
private readonly ILayoutManager _layoutManager;
private readonly IFormService _formService;
private readonly ITokenizer _tokenizer;
private readonly IClock _clock;
public FormController(
INotifier notifier,
ILayoutManager layoutManager,
IFormService formService,
ITokenizer tokenizer) {
ITokenizer tokenizer,
IClock clock) {
_notifier = notifier;
_layoutManager = layoutManager;
_formService = formService;
_tokenizer = tokenizer;
_clock = clock;
T = NullLocalizer.Instance;
Logger = NullLogger.Instance;
}
@@ -50,8 +54,12 @@ namespace Orchard.DynamicForms.Controllers {
var values = _formService.SubmitForm(layoutPart, form, ValueProvider, ModelState, this);
this.TransferFormSubmission(form, values);
if (!ModelState.IsValid)
return Redirect(urlReferrer);
if (!ModelState.IsValid) {
// We need a way to inform the output cache filter to not cache the upcoming request.
var epoch = new DateTime(2014, DateTimeKind.Utc).Ticks;
var refresh = _clock.UtcNow.Ticks - epoch;
return Redirect(urlReferrer + "?__r=" + refresh);
}
if(Response.IsRequestBeingRedirected)
return new EmptyResult();