is there a way of letting a form render without setting cookies for auto-resume?
I've got the following problem: My project (custom workflow) is a modified version of the ScoreCalculator (http://www.nibble.be/?p=83), which calculates a sum and then redirects the user to a page on a different server (payment gateway. Now If the user signs up once, everything works as it should. However if he returns to the form and fills it out again (specific case: seminar registration form and the user wants to enter several participants), the existing record in the database is overwritten, since the cookie tells the system to resume the form. Now there are two incoming payments but only one entry in the database (bad).
By googleing I found some code to delete the existing cookie. I tried invalidating/expiring the cookie inside the Workflow like this:
This has no effect at all. So I tried creating my own macro for rendering the Form by basically copying the standard Razor-Code for rendering the form and adding the cookie-invalidation:
@* First get rid of the cookie storing old form values. This is desireable in some signup-forms. *@ if (!IsPost) { if (Request.Cookies["contour_"+Model.Id+"_" +formGuid] != null) { var contourCookie = Request.Cookies["contour_"+Model.Id+"_" +formGuid]; contourCookie.Expires = DateTime.Now.AddDays(-1d); Response.Cookies.Add(contourCookie);
This causes the system to create new records in the database, when a user comes back and signs in a second time. However it has the undesired side-effect of somehow destroying the data I receive in the Workflow. The values themselves are correctly stored in the database (I can see all the entered data in the backend and each time another entry is created) but the calculation fails and the returned score (/price) is 0.
Now I ask myself, shouldn't there be the possibility to directly deactivate the setting of a cookie? Seems to me that this would be a somewhat cleaner approach than alwazs setting it and directly invalidating it (and getting a bad side effect.)
Or any other suggestions how to handle my problem?
That explains only one thing I've been wondering about. OK, yes there is no cookie set when I use the Razor macro.
That still leaves me with the previous problem, so apparently I didn't hit mark with the topic of this thread. My calculator workflow keeps on spitting out a 0 as a sum, no matter what I do. In the backend I can see the values though, so they must reach the database somehow, just not my workflow. I tried debugging, which is a pain since it seems I can't log anything and I can't send myself any emails from this workflow (don't ask me why), even if I use the sourcecode of the email-workflow and copy-paste it. The workflow just crashes and stops being executed. So I am currently clueless on how to proceed.
I receive all the values for processing without problem when using the Usercontol macro. However this one in turn has the problem of auto-resuming forms, what is undesireable in my case. Also I'm not sure, if just rooting for the Razor macro and trying to find a solution in the code is a good idea, as with coming releases of Contour the cookies will be enabled and bam I will have the same problem I'm having right now with the Usercontrols. So the best way for me seems to find out now how to disable auto-resume in general.
But what should I do when in a future version the razor macro actually sets cookies?
Another question I have now is, did something in the mail-workflow change, too? I didn't really look into it, but I somehow can't send emails anymore from my workflow.
Not even like this:
System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage(); m.From = new System.Net.Mail.MailAddress(umbraco.UmbracoSettings.NotificationEmailSender); m.Subject = "test"; m.IsBodyHtml = true;
Nope nothing changed in the mail workflow make sure you have an smtp server setyp and that the umbraco.UmbracoSettings.NotificationEmailSende is a valid email address
However we have a slight setback to the initial problem. The customer who runs the Umbraco installation which should receive the new workflow is a 4.7.11 and it won't swallow the Razor script. (Could not find namespace Mvc)
The only way for us is to render the macro via Usercontrols..
You mean I should copy over the Umbraco.Forms.Mvc.dll ?
We tried that and it crashed the system. Wasn't able to render any XSLT files anymore. The system crashed immediatly when trying to execute, save or create an XSLT file.
I can't put the dll into the live server again, too risky. So I tried making a copy of the folder structure and the database, but somehow the frontend won't render. So the only detailed error I can give you is the one I get when the Umbraco.Forms.Mvc.dll is in the bin folder and I try to create an XSLT file:
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
____
the day before yesterday, when I copied the dll into the live server I only received "Error parsing XSLT" messages on the frontend wherever an XSLT-macro should have been rendered.
Rendering a Form without setting cookies
Hiho,
is there a way of letting a form render without setting cookies for auto-resume?
I've got the following problem: My project (custom workflow) is a modified version of the ScoreCalculator (http://www.nibble.be/?p=83), which calculates a sum and then redirects the user to a page on a different server (payment gateway. Now If the user signs up once, everything works as it should. However if he returns to the form and fills it out again (specific case: seminar registration form and the user wants to enter several participants), the existing record in the database is overwritten, since the cookie tells the system to resume the form. Now there are two incoming payments but only one entry in the database (bad).
By googleing I found some code to delete the existing cookie. I tried invalidating/expiring the cookie inside the Workflow like this:
This has no effect at all. So I tried creating my own macro for rendering the Form by basically copying the standard Razor-Code for rendering the form and adding the cookie-invalidation:
This causes the system to create new records in the database, when a user comes back and signs in a second time. However it has the undesired side-effect of somehow destroying the data I receive in the Workflow. The values themselves are correctly stored in the database (I can see all the entered data in the backend and each time another entry is created) but the calculation fails and the returned score (/price) is 0.
Now I ask myself, shouldn't there be the possibility to directly deactivate the setting of a cookie? Seems to me that this would be a somewhat cleaner approach than alwazs setting it and directly invalidating it (and getting a bad side effect.)
Or any other suggestions how to handle my problem?
Not even a way to lock a Record, so it never gets overwritten?
Comment author was deleted
Hmm sure you are using the razor macro to output the form, that one shouldn't even use the cookie
That explains only one thing I've been wondering about. OK, yes there is no cookie set when I use the Razor macro.
That still leaves me with the previous problem, so apparently I didn't hit mark with the topic of this thread. My calculator workflow keeps on spitting out a 0 as a sum, no matter what I do. In the backend I can see the values though, so they must reach the database somehow, just not my workflow. I tried debugging, which is a pain since it seems I can't log anything and I can't send myself any emails from this workflow (don't ask me why), even if I use the sourcecode of the email-workflow and copy-paste it. The workflow just crashes and stops being executed. So I am currently clueless on how to proceed.
I receive all the values for processing without problem when using the Usercontol macro. However this one in turn has the problem of auto-resuming forms, what is undesireable in my case. Also I'm not sure, if just rooting for the Razor macro and trying to find a solution in the code is a good idea, as with coming releases of Contour the cookies will be enabled and bam I will have the same problem I'm having right now with the Usercontrols. So the best way for me seems to find out now how to disable auto-resume in general.
Any thoughts?
Comment author was deleted
It's due to a change in Contour, the calc method needs to be updated, I can provide a snippet tomorrow
Comment author was deleted
Here is the updated snippet
foreach (RecordField rf in record.RecordFields.Values)
{
if (rf.Field.FieldType.GetType() == typeof (Umbraco.Forms.Core.Providers.FieldTypes.RadioButtonList))
{
if (rf.Values.Count > 0)
{
var pvkey = pvs.GetAllPreValues(rf.Field).First(p => p.Value == rf.Values[0].ToString()).Id;
if (scores.ContainsKey(pvkey.ToString()))
score += scores[pvkey.ToString()];
}
}
Great, thanks a bunch! That seems to work now.
But what should I do when in a future version the razor macro actually sets cookies?
Another question I have now is, did something in the mail-workflow change, too? I didn't really look into it, but I somehow can't send emails anymore from my workflow.
Not even like this:
Thanks for the help!
Comment author was deleted
Nope nothing changed in the mail workflow make sure you have an smtp server setyp and that the umbraco.UmbracoSettings.NotificationEmailSende is a valid email address
Ok, I'll check this.
However we have a slight setback to the initial problem. The customer who runs the Umbraco installation which should receive the new workflow is a 4.7.11 and it won't swallow the Razor script. (Could not find namespace Mvc)
The only way for us is to render the macro via Usercontrols..
Comment author was deleted
You should be able to just add the mvc assembly to make it work
You mean I should copy over the Umbraco.Forms.Mvc.dll ?
We tried that and it crashed the system. Wasn't able to render any XSLT files anymore. The system crashed immediatly when trying to execute, save or create an XSLT file.
Comment author was deleted
Any details on the error?
I can't put the dll into the live server again, too risky. So I tried making a copy of the folder structure and the database, but somehow the frontend won't render. So the only detailed error I can give you is the one I get when the Umbraco.Forms.Mvc.dll is in the bin folder and I try to create an XSLT file:
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
____
the day before yesterday, when I copied the dll into the live server I only received "Error parsing XSLT" messages on the frontend wherever an XSLT-macro should have been rendered.
is working on a reply...