Code first form fields disappear/reappear on app restart
Hi,
I have a strange issue with code first forms that only occurs when the application restarts.
If the form doesn't exist, then it is created just fine, but when the app restarts for any reason (app pool recycle, web.config change, new assembly etc.) all of the form fields disappear from the front and back end. The form is still there, but none of the fields are. Another restart brings them back.
It's a really basic codefirst form, just the 2 fields. In my other project I have a custom form field which I first suspected was the culprit, but this confirms it's not that.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Umbraco.Forms.Core;
using Umbraco.Forms.CodeFirst;
using Umbraco.Forms.Core.Providers.FieldTypes;
using Umbraco.Forms.Data.Storage;
using System.Configuration;
namespace WebApplication1.Definitions
{
[Form("LoginForm", ShowValidationSummary = false,
DisableDefaultStylesheet = true,
StoreRecordsLocally = false)]
public class LoginForm : FormBase
{
[Field("Log in", "", Caption = "Email Address",
Mandatory = true,
Regex = @"(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,3})")]
public string Username { get; set; }
[Field("Log in", "",
Type = typeof(Password),
Mandatory = true)]
public string Password { get; set; }
public override IEnumerable<Exception> Validate()
{
var e = new List<Exception>();
return e;
}
public override void Submit()
{
System.Web.HttpContext.Current.Response.Redirect(umbraco.library.NiceUrl(1047) + "?done=true");
}
}
}
We're experiencing the same thing using Umbraco 4.11.8 and Contour 3.0.12, we didn't notice this issue, but were made aware of it a week ago, as with Greg, an App Restart will actually make this work for an unspecified amount of time, after which the content disappears.
Is there any news about this Tim?
using System;
using System.Collections.Generic;
using Umbraco.Forms.CodeFirst;
using Umbraco.Forms.Core.Providers.FieldTypes;
using Website.Libraries.Antenneforening;
using umbraco.cms.businesslogic.member;
namespace Website.Libraries.Contour
{
/// <summary>
/// Custom contour flow for login
/// </summary>
[Form("Onlineservice/Login", ShowValidationSummary = true, MessageOnSubmit = "Du er nu logget ind")]
public class Login : FormBase
{
/// <summary>
/// Union login name field
/// </summary>
[Field("Login", "", Caption = "Vælg forening", Type = typeof(DropDownList), Mandatory = true, PrevalueSource = "Onlineservice Login" )]
public string Forening { get; set; }
/// <summary>
/// Union login password field
/// </summary>
[Field("Login", "", Caption = "Tast-Selv-Kode", Type = typeof(Password), Mandatory = true)]
public string Password { get; set; }
/// <summary>
/// Try to login given the union/password, otherwise return what went wrong
/// </summary>
/// <returns>A list of exceptions, 0 elements if success</returns>
public override IEnumerable<Exception> Validate()
{
var e = new List<Exception>();
try
{
Method.Login(Forening, Password);
}
catch (Exception ex)
{
Password = "";
e.Add(ex);
}
return e;
}
/// <summary>
/// Login a user and add the memeber login data to cache
/// </summary>
public override void Submit()
{
Method.Login(Forening, Password);
var m = Member.GetMemberFromLoginNameAndPassword(Forening, Password);
if (m != null)
Member.AddMemberToCache(m);
}
}
}
I've noticed when codefirst forms are pulled into umbraco 7 for the first time you have to remove the two entries in the web.config otherwise i get a YSOD. They get put back in once the app has restarted. I'm not sure if this is related?
My install has quite a few code first forms and it seems pretty random which ones are missing fields, I cannot see anything obvious. Is it possible (at least in the case of u7) it could be some kind of agressive caching problem?
You've come through in the past for me when I needed prompt attention to the contour codebase...dont let me down ;-)
Ok and think I see what is happening for some reason it is removing the fields even though they don't need to be removed so fixing it now, bug fix will be available today
One last thing Tim, what's the significance of the two ContourFormBuilderHttpModule web.config entries needing to be missing on first start? Is there any other way this can be achieved? It seems a bit scrappy that I have to remember to remove them on first import.
Code first form fields disappear/reappear on app restart
Hi,
I have a strange issue with code first forms that only occurs when the application restarts.
If the form doesn't exist, then it is created just fine, but when the app restarts for any reason (app pool recycle, web.config change, new assembly etc.) all of the form fields disappear from the front and back end. The form is still there, but none of the fields are. Another restart brings them back.
Anyone encountered this before?
Greg.
Comment author was deleted
Not seen this one before, will try to repro,
Comment author was deleted
Is this on umbraco v4/V6/V7 ?
Hi Tim,
Umbraco: 6.1.6
Contour: 3.0.19
Here's a screencast from a brand new installation of Umbraco/Contour: http://screencast.com/t/zHm3K5vzv86u
It's a really basic codefirst form, just the 2 fields. In my other project I have a custom form field which I first suspected was the culprit, but this confirms it's not that.
Comment author was deleted
Thanks for the details will try to repro this week, more info soon
We're experiencing the same thing using Umbraco 4.11.8 and Contour 3.0.12, we didn't notice this issue, but were made aware of it a week ago, as with Greg, an App Restart will actually make this work for an unspecified amount of time, after which the content disappears.
Is there any news about this Tim?
Hi Tim
Any news on this issue?
I've noticed fields missing on some of my codefirst forms when I upgraded a project from u4.11 to u7.1.1.
Need a resolution to this fairly pronto.
Kind regards
Martin
Hi Tim
I've noticed when codefirst forms are pulled into umbraco 7 for the first time you have to remove the two entries in the web.config otherwise i get a YSOD. They get put back in once the app has restarted. I'm not sure if this is related?
My install has quite a few code first forms and it seems pretty random which ones are missing fields, I cannot see anything obvious. Is it possible (at least in the case of u7) it could be some kind of agressive caching problem?
You've come through in the past for me when I needed prompt attention to the contour codebase...dont let me down ;-)
Thanks
Martin
Comment author was deleted
Looking into the issue know will keep you updated
Comment author was deleted
Only syncing when in debug mode and not trying to sync otherwise would that be an option?
Comment author was deleted
And you are sure a content editor hasn't changed the forms?
Hi Tim
I testing local only at the moment so yes in debug mode.
M.
Hi Tim
I've tried running up my local instance with debugging enabled and disabled and it doesnt make any difference. Lots of forms with holes either way.
M.
Hi Tim
I've just taken a look at the UFFields table and it's missing rows. So the import process on application start isnt working correctly.
M.
Comment author was deleted
Ok I can reproduce the issue, looking into a fix now, hope to have it ready today!
Phew cheers Tim.
M.
Comment author was deleted
Ok and think I see what is happening for some reason it is removing the fields even though they don't need to be removed so fixing it now, bug fix will be available today
Thanks Tim you rock!
Comment author was deleted
Of found it was a stupid type, build server is running now
One last thing Tim, what's the significance of the two ContourFormBuilderHttpModule web.config entries needing to be missing on first start? Is there any other way this can be achieved? It seems a bit scrappy that I have to remember to remove them on first import.
M.
Comment author was deleted
@Martin could you create new forum topic for that :)
Sure :)
Comment author was deleted
@Martin thanks, that way it's easier to keep track :)
For the missing fields could you give http://nightly.umbraco.org/Umbraco%20Contour/3.0.21/ a try
And let me know if that fixes it (should also fix a YSOD you can get when first importing the form)
AWESOME! fields back to normal no YSOD!
I was hoping to attend CG14 but family pressures mean i've had to dip out another year! :-(
When I finally get the chance to attend CodeGarden, I owe you quite a few beers!
All the best
Martin
Comment author was deleted
Great thanks for confirming :) There is also the Uk festival ;) should be in october/november!
Thanks, Tim, I'll give it a whirl and let you know how it goes.
Greg.
I'll look out for it. :-)
M.
is working on a reply...