05 January, 2016

Episerver connect for sharepoint

The "sharepoint connector" is now a days a scheduled job with a settings page. (in earlier versions of Episerver the sharepoint connector worked in a very different way)

What it does is essentially to copy files from the connected sharepoint instance to the Episerver blob storage.
This means that the copied files will be available in the content folder as if the editors uploaded them by them selves.
The scheduled job will compare the files and update or delete files if it finds changes.

How to install Episerver connect for sharepoint

The installation process is as easy as installing a nuget package.

Compile your project, start the site and go to admin mode.
You will now see a new scheduled job named "SharePoint Update"
And on the config-tab below "Tool settings" you will find "Connect For Sharepoint"
Because of a bug in the present version of Episerver Connect for Sharepoint you might not see the tool settings if you dont have set english as your perfered language. (You can change this in your personal settings. You will find it in the top right corner (click on your login name and you will find it)

How to configure Episerver connect for sharepoint

  • In Episervers admin mode, on the config tab, click "Connect For Sharepoint"
  • In "Site URL" add the url to your sharepoint site. If you use microsofts colud services for sharepoint it will look something like this "https://yourcompany.sharepoint.com/"
  • Use a username and password for an account that has privileges to read the information you want to sync to Episerver.
  • If you are using microsofts colud services for sharepoint  select  "Connectiontype - Online" otherwise if your sharepoint server is in your local network, select "Connectiontype - On-premises".
  • Hit "Test connection"
  • You should now se a list of lists that your username has access to.
  • Check those you would like to "sync" (or more correct want to copy to episerver on the set interval)
  • In "Select Folder" you select a folder from the Episerver media library that you want to sync the selected SharePoint information to
  • Hit Save
  • Now the first time copy will start. If it doesn't, hit the Refresh button at the bottom of the page.



Yippee, now you have configured Episerver connect for sharepoint!
You can check the media library in editmode to see that the files show up in the folder you selected.

Now it's time to check that the scheduled job named "SharePoint Update" is set to run on a suitable interval.
Go to Admin mode - Scheduled jobs - SharePoint Update and be sure to check the Active checkbox and adjust the interval for your needs.

That's it. Your now worth a cup of coffee :-)

09 April, 2015

Red lines under model and PropertyFor in EPiServer and MVC

Do you get the annoying red lines in Visual Studio under for instance @model and @PropertyFor In your views when developing an EPiServer site with MVC?

It's because you reference an old version of Razor and MVC in your web.config file (the one in the views folder)

<configSections>
  <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
  <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
  </sectionGroup>
</configSections>
<system.web.webPages.razor>

  <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />


31 July, 2013

EPiServer sites with long start up time

Some sites built on EPiServer (mostly with Relate+) might be slow to start after a deploy. It can in worst case take several minutes for the site to compile and start.

To solve this you can add optimizeCompilations="true" to the Compilation tag i web.config

 <compilation defaultLanguage="c#" debug="false" targetFramework="4.0" optimizeCompilations="true" >


By adding optimizeCompilations="true" to the compilation tag we can improve the start up performance of our site considerably, but you might experience run-time errors if you delete, rename or change the signature of a method referenced by an already-compiled page. If this happens simply set it to false, rebuild and then set it to true again.

One of those errors could be "Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."

23 April, 2013

Errors while updating from EPiServer 7.0 to 7.1

Errors when updating from EPiServer 7.0 to 7.1 in the Add on store


Error #1

You update by using EPiServers built in Add-on system and suddenly the Editmode tab and possibly the Add-on tab disappears.

The problem is that the update removes the old add-ons and then crashes with no rollback because it can't overwrite files in the modules and modulesbin folders in the site.

To repair this, copy the folders Modules and ModulesRepository (usually located in the vpp-folder) from a working site.
Then restart the site.

Now it works, but is still in the old version.

Ensure that the files in modules and modulesbin folders in the site are not write protected and accessible by the system.

Try to update through the add-on tab again.

Error #2

You update by using EPiServers built in Add-on system. The Editmode remains but the content of Edit mode is blank (white)

Try to clear the .net cache
It's usually stored in a folder that looks like this: "c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\"

Restart the site

Error #3

You update by using EPiServers built in Add-on system. And then the site responds with "An item with the same key has already been added."

You probably have the same dll in both the bin and modulesbin folder.
Remove the duplicate from the bin folder (probably EPiServer.Cms.Shell.UI.dll)

25 February, 2013

Cannot find form to submit

I added an XForm to a page in EPiServer 7 using the built in XForms functionality.

When the user submitted the form they got the following error:

Cannot find form to submit (in EPiServer.XForms.WebControls.Submit.SubmitForm)

My stupid mistake was that I accidentally datda bound the xform property on page load...

I had a placeholder around it to control what to display when, and I data bound it without checking for post back... (I know, a newbie misstake ;-) )


 protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //FormPlaceHolder.DataBind();
            if(!IsPostBack) FormPlaceHolder.DataBind();


Stupid mistake, easy solution :-)

19 November, 2012

Null reference in EPiServer filemanager

You get the following error when trying to open a folder in the EPiServer file manager.


[NullReferenceException: Object reference not set to an instance of an object.]
EPiServer.Web.Hosting.Versioning.VersioningFileSummary..ctor(FileItem file, FileOperations fileOp)

This might happen if the file on disk is removed but the reference to it is still in the EPiServer database. It can also happen if the versioning data has become corrupt for some reason.

I solved it by creating the following simple page/tool:

ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FixFiles.aspx.cs" Inherits="QD.Web.FixFiles" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" OnClick="Button1_Click" runat="server" Text="Deleting files where source don't exist" />
        <asp:Label ID="StartIndexOnItemLit" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>

Code behind
using System;
using System.Text;
using System.Web.Hosting;
using System.Web.UI;
using EPiServer.Web.Hosting;

namespace QD.Web
{
    public partial class FixFiles : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void Button1_Click(object sender, EventArgs e)

        {
            StartIndexOnItemLit.Text = "";
            var builder = new StringBuilder();
            VirtualPathHandler instance = VirtualPathHandler.Instance;


            foreach (VirtualPathProvider a in VirtualPathHandler.Instance.VirtualPathProviders.Keys)
            {
                if (a is VirtualPathUnifiedProvider)
                {
                    VirtualDirectory dir = instance.GetDirectory((a as VirtualPathUnifiedProvider).VirtualPathRoot, true);

                    foreach (object element in dir.Children)
                    {
                        CheckItem(builder, element);
                    }
                }
            }


            StartIndexOnItemLit.Text = "<ul>" + builder + "</ul>";

        }


        private void CheckItem(StringBuilder builder, object element)

        {
            if (element is UnifiedDirectory)
            {
                CheckDir((element as UnifiedDirectory), builder);
            }

            if (element is UnifiedFile)
            {
                CheckFil((element as UnifiedFile), builder);
            }
        }

        private void CheckDir(UnifiedDirectory dir, StringBuilder builder)
        {
            try
            {
                builder.AppendLine("<ul>");

                foreach (object a in dir.Children)
                {
                    CheckItem(builder, a);
                }

                builder.AppendLine("</ul>");
            }

            catch (Exception error)

            {
                builder.AppendLine(dir.Name + " " + dir.VirtualPath + " " + error.Message + " " + error.StackTrace);
            }
        }

        private void CheckFil(UnifiedFile fil, StringBuilder builder)
        {
            try
            {
                IUnifiedSummary a = fil.Summary;
            }
            catch (Exception error)
            {
                builder.AppendLine("<li>deleting file since source don't exists " + fil.VirtualPath + "</li>");

                fil.Delete();
            }
        }
    }
}


15 November, 2012

Sys.UI is undefined when using Component Art


I had a hard time finding out why i got the "Sys.UI is undefined" error on a page.

After some trouble shooting I found out that the problem was that I use Component Art to render a calendar on my page and the Coponent Art dll was for .net 3 not .net 4 which was the version of my project.

So the solution was to download the new version from Component Art, install it and then reference to the new version in my project.