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 ASP.Net Core currently runs only runs on old-style ASP.Net MVC, not on on the full .Net framework. An ASP.Net Core .  An ASPon .Net Core version of the CMS is in developmentwill be developed in the near future.

To set up an MVC 5 websiteASP.Net Core website on full .Net, do the following:

Image RemovedImage Added

Select ASP.Net Core Web Application (.Net Framework) as the project type.

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 RemovedImage Added

Choose the MVC template

Install Lynicon

To install Lynicon find Web Applicatin 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. 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 the LyniconANC package.

Set 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.

Build the Site

Now build the site so that you can use the output executable to run setup commands.

Run Command to Initialize Project

Find the folder in which the output executable from the build is found e.g. something like C:\Dev\MyProject\src\MyProject\bin\Debug\net452\win7-x64.

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

Image Added

Move (cd) to this directory, and run the command <project name>.exe lynicon initialize-project e.g. as underlined above. 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.  If you have problems, refer to the page which describes the changes you need to make to the Startup.cs file.

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 webappsettings.configjson, set the value for the connection string element in the configuration section 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>

initialize-project command:

Image Added

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:

...

to update it with the changes made by the initialize-project command.

Run the Initialize-Database command

Go back to the command window.

Image Added

Run <project name>.exe lynicon initialize-database.  This will connect to the database with the connection string provided and set up the core tables Lynicon requires.

Disregard an error message produced by log4net, it will work without the configuration it needed in ASP.Net MVC which it is requesting be set up.

Run the Initialization-Admin Command

Image Added

Run <project name>.exe lynicon initialize-admin <admin password>.  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.