EPiServer Forms – Quick Start

I was asked once by a client to build some functionality that allowed editors to create forms on the fly without developer effort. EPiServer did the work for us. Here’s an overview on Forms.

Out of the box EPiServer Forms boast the following form elements ready to use:

  • Text, Text Area, Number, DateTime, Range, Url, Rich text
  • Selection, single/multiple choice
  • Image, File uploads
  • Hidden Values, Hidden Visitor Profiling
  • Captcha, Recaptcha
  • Form, Submit, Reset buttons.

All in all, covers most scenarios.

To get started:

  1. Install EPiServer.Forms package via NuGet in Visual Studio
  2. A new tab called Forms will appear in your assets pane alongside Media and Blocks tabs
  3. Click the create new form button in the Forms tab
  4. Once you’ve populated some details about your form, Create it and then you will see a new Forms Elements section in the Forms Tab. From here you can drag over what you need into the form.
  5. At the very minimum you should drag the Submit button over to allow a user to submit the form.
  6. The form itself in the settings tab allows you to add a list of email recipients for where the form data will be sent to.
  7. The form is block based and thus must be dragged into a Content Area for it to be used.

This is your basic form done. Within that you can configure all the out of the box form elements. There are lots of options such as setting Required flags, range limits, regular expressions and even formats.

EPiServer documentation as a create selection of how-tos for different types of forms: http://webhelp.episerver.com/latest/addons/episerver-forms/form-examples.htm

Exception: Cannot find compilation library location for package ‘Microsoft.AspNetCore’

System.InvalidOperationException: Cannot find compilation library location for package ‘Microsoft.AspNetCore’

Most likely you’ve upgraded your aspnetcore version and you have not cleared the existing files before deployment.

If you’re using Azure DevOps as your build and release server you can enable “Remove Additional Files at destination” on your release step.

AspNetCore Debugging Startup issue in Azure Web App

Whilst upgrading from AspNetCore 2.0 to 2.1, some of the StartUp configuration had changed slightly and part of the upgrade required me to refactor code into the webhost builder. However as a result I didn’t quite do everything and after deploying to azure web app, I was hit with a 502 response. An exception being thrown in main(). This was a problem because it was happening before it could get to my logging initialization and therefore no logging was happening.

So in order to debug Azure Web App AspNetCore startup issues we need to enable stdout logging which throws all exceptions to a log file. This method of logging is unfiltered and gets heavy very quickly. Therefore it is inadvisable to keep it turned on.

Enable STDOUT on Azure Web App

  1. Go to your azure web app in Azure Portal
  2. Open Kudu Console
  3. Using the navigation bar at the top of the page, open Debug console and select CMD
  4. Navigate to folder site > wwwroot
  5. Edit the web.config
  6. Set stdoutLogEnabled to true and stdoutLogFile to \\?\%home%\LogFiles\stdout
  7. Select Save
  8. Make a request to the application url
  9. In Kudu, navigate to the LogFiles folder
  10. Open the new files marked with stdout
  11. When the log file opens, the error is displayed.
  12. you must disable stdoutLogEnabled by setting to false when you are done


Source: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/azure-apps/troubleshoot?view=aspnetcore-2.1#aspnet-core-module-stdout-log

EPiServer Find Index – unknown property

This particular nugget has screwed with me for a few days. When attempting to run a standard EPiServer Find index, my log files were getting flooded with this:

An exception occurred while indexing (Content): MapperParsingException[failed to parse [Blocks.Items.Blocks.Items.DefaultPrice.UnitPrice.Currency]]; nested: ElasticSearchIllegalArgumentException[unknown property [CurrencyCode$$string]]; .

Contact episerver support to get them to move your index to a new cluster. In my case it was confirmed by EPiServer support that it was a timeout issue with regards to a bad cluster the index is sitting on.

Similar: https://support.episerver.com/hc/en-us/articles/115004105763-Find-Index-Timeout-with-OnPublish-Event

Visual Studio 2017 – Add, Remove or Update DotNetCLITools references – 7th March 2017

Visual Studio release notes as of 7th March release notes state that the DotNetCLITools packages cannot currently be managed by the Nuget Package Manager and must be edited manually in the csproj.

After migrating my current projects, I finally figured out that it wasn’t just me that was struggling to find the place to manage these packages. There’s no intellisense in this area either. Eventually I replaced my pre-release references with the following:

In your csproj file: 

    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" />
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
    <DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.301" />

This allows visual studio to run the dotnet commands for building, database, bundling and publishing!

Sources: https://www.visualstudio.com/en-us/news/releasenotes/vs2017-preview-relnotes