mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#5260: Fixed the issue where form validation result gets output cached.
Fixes #5260
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user