Getting Started

To illustrate with an example, this walkthrough sets up an ASP.NET Core MVC project using ASPSecurityKit.NetCore NuGet package. Please follow similar steps for other ASPSecurityKit’s platform packages such as ASPSecurityKit.NetFramework.Mvc, ASPSecurityKit.NetFramework.WebApi or ASPSecurityKit.ServiceStack (substituting specified project template, ASK NuGet and source packages with equivalent for the chosen platform).

For any question or to report any issue, feel free to contact us at [email protected]

Before you begin

This walk through requires:

  1. You’ve read the introduction article and have familiarity of two types of ASPSecurityKit packages: library and source packages.
  2. You’ve bought an ASPSecurityKit plan to generate the license key. If you instead want to evaluate ASPSecurityKit before purchasing the license, you should follow the trial walkthrough.
  3. This walkthrough uses the Starter (ASP.NET Core Mvc) source package to demonstrate the power and ease of getting important web operations (such as sign up, sign in, account settings, forgot password, email verification etc.) into your new project without having to write a single line of code. You can buy a Starter source package against your ASPSecurityKit library license from the dashboard. By default, you get the Essential source packages free with the library license (the project license) which doesn’t come with these operations.

Create the project

  1. In Visual Studio, open the New Project dialog.
  2. Choose the programming language as CSharp and ASP.NET Core Web Application as the template.
    ASP.NET Core Web Application C# Project Template
  3. Provide the project name and other information.
    Project Name and location form
  4. Choose the Empty project template and click on the Create button.
    ASP.NET Core Web Application Empty Template

Install the ASPSecurityKit library package

As part of this step, we’ll install the ASPSecurityKit.NetCore NuGet package, which provides full ASPSecurityKit capabilities to build secure and reliable modern MVC web applications and API platforms on the ASP.NET Core. Check out the comprehensive security pipeline article to understand the multi-stage identity and access verification workflow ASPSecurityKit provides.

  1. Open Package Manager (PM) Console and make sure that the selected project is the web application project just created.
    Package Manager Console
  2. Type the following command and hit enter:
install-package ASPSecurityKit.NetCore

Package manager console showing result of installing ASPSecurityKit.NetCore Package command execution
3. Make sure that the package installs successfully

You can also use the Package Manager UI to install the above package.

Install the source package into the project

As part of this step, we’ll install the Starter-ASP.NET Core Mvc source package. A source package gives you useful functionality in source code form. In addition to essential components, this particular package provides important end-to-end implementation of web operations (such as sign up, sign in, account settings, forgot password, email verification etc.) as well as graceful error handling and error pages into your new project without having to write a single line of code. Since it comes as source code, you can customize as per your project needs.

Follow these steps to install a source package. On the ‘Install a Source Package’ screen, make sure you select NetCoreMvc as the platform and Starter as the source package. If the package doesn’t appear, it means you haven’t bought it. You can click on Show all checkbox and then click on the Buy button to purchase this package.

NetCore platform and Starter source Package selections on the installer form

Upon successful installation, you should see several new items added to the project.

Solution explorer showing source files added by the Starter source package

Next, make sure you also install the node dependencies. The Starter ASP.NET Core Mvc source package we’ve just installed have some script dependencies such as bootstrap, jquery, jtable, etc. which have been configured as NPM dependencies.

Generate license key for the project

You cannot perform subsequent steps without generating a license key for this project because the number of operations permitted for trial has been exceeded by the source code you’ve obtained from the Starter-ASP.NET Core Mvc source package.

Important: once a license key is generated, it cannot be revoked. It’s valid for the project it is generated. So do not generate a license for trying out as you’ll not be able to reuse it in other projects. For trial, follow this walkthrough instead.

Follow these steps to generate a license key. On the ‘Generate License Key’ screen, make sure you select NetCoreMvc as the platform. If no subscription appears, it means you either haven’t bought one or have consumed it already. You can click on ‘Buy More’ to open Dashboard to purchase a new subscription.

NetCoreMvc platform selection on the Generate License Key form
Solution explorer showing ASPSecurityKit License key File, AskLicense.dat

The Starter-ASP.NET Core Mvc source package comes with a logic that makes call to License.TryRegisterFromExecutionPath which instructs ASPSecurityKit to automatically locate and register the license key from file.

Create the database

The Starter-ASP.NET Core Mvc source package we had installed in a prior step, comes with EF migrations and T-SQL scripts so you can create the database backing the models of your new project immediately.

  1. Verify the connectionString: Open appsettings.json file from Solution Explorer and verify that the DefaultConnection has a valid connectionString as per SQL Server version available on your machine. If it’s not, make the appropriate changes.

    ASPSecurityKit NetCore Mvc app settings

  2. Open Package Manager Console and make sure that the selected project is the web application project we’ve been working with in this walkthrough.

  3. Type the following command and hit enter:

update-database
Package manager console showing result of update-database command execution
  1. If you receive an error stating something like:
    • “The term update-database is not recognized as the name of a cmdlet, function, script file, or operable program.”, you should close and restart Visual Studio, and open the same solution. For more information about this issue, check out the troubleshooting section.
    • “This Evaluation license has a quota of … operations for NetCore feature which has been exceeded.”, you likely don’t have the license key generated and the trial limitations have been exceeded. For more information about this issue, check out the troubleshooting section.
  2. Make sure that the database is created successfully.
    • You will see messages something like “Applying migration …”. If all goes well, the last message that you see is “Done” (with EF Core; with EF framework, it’s “Running seed method”).
Sql server management studio object explorer showing database tables and SPs created by EF migration that comes with ASPSecurityKit Starter Package

Application Configuration

The Starter-ASP.NET Core Mvc source package has also come up with some useful configuration settings that the accompanying source components make use of. You can have a look at them in the ‘app’ section of the appsettings.json file in the project root.

By default most are populated with default value or values you provided on the second step of the ‘Install a Source Package’ screen. Following settings related to email component aren’t populated by default and are required for email verification and forgot password flows to work:

    "app": {
        "MailId": "[email protected]",
        "MailPassword": "password",
        "MailProvider": "Gmail",
    },

The above settings are used by the Mailer component installed as Infrastructure\Mailer.cs in your project. MailId and MailPassword settings are self-explanatory; the MailProvider setting can take one of three values: Gmail, Outlook, or Yahoo. The Mailer component is preconfigured to work with these popular email providers; since you have the source with you, you can extend it to work with any additional provider you prefer.

Try it out

Press F5/ctrl+F5 to run the application. You can sign in using the [super admin] credentials – username as in the settings and the default password ‘admin’. You can also sign up and try out flows like email verification and account settings.

Congratulations for installing ASPSecurityKit! You are going to absolutely love the secure, flexible and rapid development basis it provides for your project!