pure mvc widget with form submit - caching problem
Hi,
I have been developing on ASP.Net since the early days (2002), a few years ago I started with ASP.Net MVC and just recently (1 week :-) ago) started with the implementation of a Sitefinity CMS for one of our customers.
Because I, and the company I work for, love ASP.Net MVC, we are using Pure MVC mode in SiteFinity.
I am currently developing a small MVC widget that contains a simple form (just for testing purposes), my Controller looks like this:
[ControllerToolboxItem(Name =
"SimpleFormWidget"
, Title =
"Simple Form"
,
SectionName =
"Forms"
)]
public
class
SimpleFormWidgetController : Controller
public
ActionResult Index()
var model =
new
SimpleFormWidgetModel();
return
View(
"Default"
, model);
[HttpPost]
public
ActionResult Index(SimpleFormWidgetModel model)
if
(ModelState.IsValid)
model.IsSubmitted =
true
;
return
View(
"Default"
, model);
public
class
SimpleFormWidgetModel
public
bool
IsSubmitted
get
;
set
;
[Required]
public
string
Name
get
;
set
;
@using Telerik.Sitefinity.UI.MVC;
@model SitefinityWebApp.Mvc.Models.CallMeBackWidgetModel
@if (Model.IsSubmitted)
<
p
>
Thank you for submitting the form.</
p
>
else
using (Html.BeginFormSitefinity())
<
p
>
@Html.LabelFor(m => m.Name)
@Html.TextBoxFor(m => m.Name)
</
p
>
@Html.ValidationSummary(false)
<
button
type
=
"submit"
>
Send</
button
>
Hi Marien,
For Pure mode use Html.BeginForm as described in this documentation. To avoid MVC cache above the controller action method use as an attribute
[System.Web.Mvc.OutputCache(NoStore =
true
, Duration = 0, VaryByParam =
"*"
)]
Hi Stanislav,
Thank you for your reply.
I had changed Html.BeginForm to Html.BeginFormSitefinity because I got a javascript error message when editing the page with the widget on it that contained the Html.BeginForm.
I have tried what you have described: I changed Html.BeginFormSitefinity to Html.BeginForm, put the [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")] attribute on both the Index methods (also the one with [HttpPost] attribute, and this is what happened:
Hi,
I believe the problem is connected with way the postback on the Html.BeginFormSitefintiy is used at your MVC classes. Can you also check if changint the page cache will have effect in addition to already having
[System.Web.Mvc.OutputCache(NoStore =
true
, Duration = 0, VaryByParam =
"*"
)]
@Marien: I'm sure you tried to turn-off the cache on a global level? (Settings -> System -> Output Cache?
Just my 2 cnts... :)
Hi Daniel,
That was one of the first things I tried. Didn't help either.
I created a support ticket for this issue on the 29th of march and it's still open, Telerik expects to have this bug fixed in SP1 for Sitefinity 6.
You sure they didn't say SP2 or 6.1?
www.sitefinity.com/.../sitefinity-6-0-sp1-released
Hi Steve,
That's interesting, in the last post of our support ticket Boyan Barnev wrote that the bug has officially been scheduled for the upcoming ServicePack.
He wrote this on may 7th, so I assumed it would be SP1. The bug is not listed as fixed and our support ticket also has not been updated. I will send a reply on our support ticket to get some clarification.
Not ever fix is always in the notes, keep us updated please :)
I would also like an update on this!
I haven't received an update yet from Telerik. Still the same status as one month ago.
Hello,
The problem is now in the stage of testing in order to be added in the next sitefinity release this month in July.
Regards,
Stanislav Velikov
Telerik
Hi Stanislav,
Thanks for the update.
Kind regards,
Marien