Invite us into your inbox! We promise we won't overstay our welcome - we'll pop up once a month with updates on industry trends, best practices & new strategies. 

Coding with Bob: Building an Episerver Site from Scratch - Part 1

While most new Optimizely + Episerver developers tend to learn on the job through maintenance projects, Blend believes that there's a lot of value in learning how to spin a site up from scratch. Blend's Director of Development Bob Davidson provides some guidance on how to do just that in this Coding with Bob video.

7/1/2021

Authored by

Categorized

  • Development
  • Optimizely

It's common for developers who are new to Episerver to learn on the job. Frequently they start out doing maintenance on existing projects. They cut their teeth on projects that have already been configured and architected. While this may ease the learning curve (and ensure new projects are set up to team standards), it can leave gaps in knowledge. A developer may learn about content modeling, scheduled jobs, views, and other items that require frequent updates and bugfixes, but might not receive much exposure to lower level concepts such as how content rendering works. The line between Episerver and MVC may be blurry. Much of the system may feel like voodoo.

I think it's useful to build at least one Episerver site from nothing, using (almost) no frameworks, going through each step manually and really understanding what's happening at each point. It's helpful to take the time to understand all of the black magic in the boilerplate code we seem to see in project after project.

To that end, I've started a video series walking through creating a new Episerver site from scratch. The first step, setting up a new, blank Episerver project is documented in the quick video below:

 

Video summary steps.

Create the solution and project.

1. Create a new Solution.
2. Using the Episerver Add-On, create a new Episerver site. Use the Empty template. For our purposes, do not install the Alloy content and code.

Create the database.

By default, the site will be configured to create a Local DB in your AppData directory. Generally, it's preferable to create an empty database in an actual SQL Server instance.

  1. In the .\packages\EPiServer.CMS.Core.11.15.1\tools folder, you'll find the EPiServer.Cms.Core.sql file. (Note: the actual version number in the path, 11.15.1, will likely be different for you. Just look for the newest EPiServer.CMS.Core folder). You'll need this file.
  2. Create a new, blank database within SQL Server: CREATE DATABASE EpiserverExample;. Name the database (EpiserverExample here) whatever you prefer.
  3. Run the EPiServer.Cms.Core.sql file against your new database.
  4. Update your connection string for the database. It will look something like :<add name="EPiServerDB" connectionString="Data Source=.;Initial Catalog=EpiserverExample;Connection Timeout=60;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />.
    • The name must be EPiServerDB.
    • The Data Source should be your local SQL Server instance.
    • The Initial Catalog is whatever you named your database.
    • Integrated Security=True works for me because I'm running IIS Express and my Windows account has full access to the database. Otherwise, you may need to create a SQL login/user and grant it access to the database.
    • MultipleActiveResultSets=True is required for Episerver to run correctly. Do not forget this.

Launch the site.

The first time you launch the site, you will get a Resource cannot be found 404 error. This is expected. There is no homepage yet, so it makes sense it cannot be found.

Go to /Episerver, you should see a login page. There, if you're using a standard Windows account, you should be able to log in. This is because by default, the site configured for Multiplexing authentication with ASP.NET Membership. While that's convenient, I would recommend removing it in favor of Identity Framework. But that's a future blog post.

Blend's Director of Development, Bob Davidson, provides tutorials on all things development.

His web series, Coding with Bob, can be found on Youtube. Check it out!

Across the web.

Here's somewhere else you might find Bob beyond Blend.

Coding with Bob

Coding with Bob is a YouTube series by Blend's Bob Davidson: a little .NET coding, a little Optimizely development work, and a few things related to both.