Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This subject shows how to create a new site running Lynicon ASP.Net Core in Visual Studio 2015.

Create Solution

Lynicon currently only runs on old-style ASP.Net MVC, not on ASP.Net Core.  An ASP.Net Core version of the CMS is in developmentASP.Net Core targets .Net 4.6 or .Net Standard 1.6 (which works with .Net Core)

Info

If you can't see the ASP.Net Core project types below, you'll need to install .Net Core tools from the web.


To set up an MVC 5 website, do the following:

Image Removed

Select ASP.Net Web Application as the project type.ASP.Net Core website, choose 'ASP.Net Core Web Application (.Net Core)' below for an application running on .Net Core, or 'ASP.Net Core Web Application (.Net Framework) for an application running on full .Net 4.6.  The subsequent steps are all the same regardless of what platform you choose here.

Image Added

Warning

Do not call the new Solution or Project 'Lynicon' (or Lynicon.Base or any other such name) as it will cause assembly linking problems

Image RemovedYou'll now see the following window:

Image Added

Choose the MVC template

Install Lynicon

To install Lynicon find Web Application template. Ensure the Authentication choice is No Authentication as this package sets up its own ASP.Net Identity based membership system.

Install Lynicon

Before installing Lynicon, you should ensure certain dependencies in your project are sufficiently up to date not to clash with Lynicon's dependencies.

Image Added

Edit the project.json file if necessary to ensure Microsoft.AspNetCore.Mvc is at least version 1.1.1, Microsoft.AspNetCore.Routing is at least 1.1.0, and Microsoft.Extensions.Logging is at least 1.1.0. If you are using the full .Net platform, ensure the framework specified includes "net46" at least. When you save this file, Visual Studio will automatically restore packages.

Now install Lynicon. Find it in the Nuget Gallery on nuget.org

Image RemovedImage Added

Choose Lynicon.Identity the LyniconANC package.

Set

...

Determine a SQL database locally or remote which will host the content and user data.  In web.config, set the value for the connection string element which has been created by the installation, and also the DefaultConnection connection string which already existed (ensuring user tables are created in the same database as content tables):

Code Block
languagexml
  <connectionStrings>
    <add name="DefaultConnection" connectionString="..."  providerName="System.Data.SqlClient" />
    <!-- Add lynicon database connection string here, or delete if no database being used -->
    <add name="LyniconContent" connectionString="..." />
  </connectionStrings>

Build the Site

Run a build on the site as the commands you are about to run will load the current site's compiled code in order to enable them to execute, and they won't work without this step.

Build the Database

If you used the default connection string from the project scaffolding which points to an .mdf file in App_Data, you will need to ensure the database is created before running the initialization commands.

Image Removed

These initialize and activate Entity Framework Migrations.

  • Enable-Migrations: this sets up the project for migrations
  • Add-Migration -Name Init: this creates the first migration to create the database with ASP.Net Identity tables set up
  • Update-Database: this runs the migration

Run the Initialization Commands

Image Removed

Go to the Package Manager console.  Lynicon has installed Powershell commands to set up the CMS.  The commands to run (in this order) are shown in the image.  They are:

...

up Lynicon commands

Now add a line of code that will enable you to use the executable which normally runs the Kestrel webserver with your site to run Lynicon service and setup commands:

Image Added

Add the highlighted line of code above into your Program.cs file in the root of your project.

Run Command to Initialize Project

Find the folder in which the project is found e.g. something like C:\Dev\MyProject (or according to solution structure, C:\Dev\MySolution\src\MyProject).

Open a Visual Studio developer command window as Administrator (right click the menu item and choose Run as Administrator).

Image Added

Move (cd) to this directory, and then using the dotnet CLI, run the command "dotnet run lynicon initialize-project" e.g. as underlined above. First this will build your project. Then this tells your project executable to run a command to download new files and update existing ones in your project.  This command makes a number of changes to the Startup.cs file.  This will work with the Startup.cs file provided with the template we have used to create this project in these instructions.  It should work with most customised Startup.cs files, especially if you follow standard C# formatting, but it is not guaranteed to work.  You can check all its operations succeeded by inspecting its output, at the top it describes whether it succeeded in modifying files, then it lists all the files it has downloaded into your project. If you have problems, refer to the page which describes the changes you need to make to the Startup.cs file.  If the command fails altogether, you can follow the steps to manually initialize the project.

Leave the command window open after this as you will need it later.

Set the Connection String to the Database

Determine a SQL database locally or remote which will host the content and user data.  In appsettings.json, set the value for the connection string in the configuration section which has been created by the initialize-project command:

Image Added

Run the Initialize-Database command

Go back to the command window.

Image Added

Run "dotnet run lynicon initialize-database".  After building your project again, this will connect to the database with the connection string provided and set up the core tables Lynicon requires.

Run the Initialization-Admin Command

Image Added

Run "dotnet run lynicon initialize-admin <admin password>" (use your own password in place of m1pAssw0rd!).  This sets up the admin user with the supplied password.  Lynicon does not create a default admin user to avoid the scenario where this user is left with their default password causing a major security risk.

Confirm the output from this command looks as below:

Image Added

You are now ready to use Lynicon CMS.

First Run

If you now run the site and log in as the administrator on /lynicon/login you will be able to see the Lynicon pages as described in the User Manual.  Lynicon is now ready to be used for CMS functions.

...

To now set up a basic content-managed model, route and view, consult the Hello World page.