Dominik Juszczyk Technical blog

23May/081

Get posted data (XFormData) from XForm

Recently we have had to get posted data from xform from code. To do it we developed this method:

/// <summary>/// Retives posted data for xform defined for CurrentPage.
///</summary>
/// <param name="pageReference">PageReference of page for each posted data of xform should be returned</param>
/// <param name="xFormPropertyName">Property name of CurrenPage page type. Property has to be of type XForms</param>
/// <param name="xFormFolderPath">XFormFolder path where xForm is saved.</param>
/// <returns>Returns list of XFormData objects - each XFormData object contains data posted with xform</returns>

private IList<XFormData> GetXFormData(PageReference pageReference, string xFormPropertyName, string xFormFolderPath)
{
   if (pageReference == null || pageReference == PageReference.EmptyReference)
       return null;

   PageData pageData = GetPage(pageReference);

   PropertyData xFormProperty = pageData.Property[xFormPropertyName];
   if (xFormProperty == null || xFormProperty.Value == null)
       return null;

   if (!(xFormProperty is PropertyXForm))
       return null;

   IList<XForm> xFormFolder;
   if( xFormFolderPath != String.Empty )
       xFormFolder = XFormFolder.GetForms(xFormFolderPath);
   else
       xFormFolder = XFormFolder.GetForms();

   foreach (XForm xform in xFormFolder)
   {
       Guid formGuid = new Guid(CurrentPage[xFormPropertyName].ToString());

       if (formGuid.CompareTo((Guid)xform.Id) == 0)
       {
           return xform.GetPostedData(CurrentPage.PageLink.ID, DateTime.Now.AddDays(-7), DateTime.Now);
       }
   }

   return null;
}

It gets as parameters PageReference of page for which posted data should be returned, property name of property that contains XForm and folder name where xform is stored (if any). As output from method we get list of XFormData objects where each item contains data posted with xform.
It works in EPiServer CMS 5 where some changes in XForm handling has been introduced (strong typing).
Here is post on forum where is shown how to do it in EPiServer 4.6x.

13May/080

WebResource.axd problem in EPiServer CMS 5

With our first EPiServer CMS 5 based solution we had strange problem related with WebResource.axd. We were getting the exception:

The WebResource.axd handler must be registered in the configuration to process this request

After searching for this exception in Google I have found a post about this on Fredrik Haglund's blog. We have had applied his patch and it seems to solve the problem (at least until it will be solved by EPiServer or whoever responsible for that).
Anyway I thought that we did something special in that one project and that this problem is that project specific only. Unfortunately it occurred that the exception is thrown from time to time in all our EPiServer CMS 5 projects. The worst thing is that we are not able to reproduce error or identify what makes this error more probable to occur. It is thrown from time to time without any clear reason.
For now we have started to adding patch to all ours CMS 5 projects. But this is something that has to be solved somehow. We are monitoring EPiServer's forum and waiting for this problem to be solved. When you will read comments to the Fredrik's post you can see that they are working on that - and I will keep my finger crossed for them to fix it :)

UPDATE:
Today I have found this post. It seems that the reason of error has been found and that there is a workaround.