How to install ASP Security Kit package in your ASP.NET Mvc project and troubleshoot installation issue

ASP Security Kit comes preloaded with many models, controllers, EF migrations, T-Sql scripts, views, javascript files, helpers and services as source files that are to be installed into your Mvc project directly. To properly install all of these into your projects and to manage the same for future updates and patches, we needed much more granular control on the installation process. For this reason, we opted to use tooling capability of NuGet and built a custom package installer with transformations required for ASP Security Kit. The actual package files are downloaded from https://ASPSecurityKit.net/ by Powershell -based installer upon authentication.

Steps to install

New project dialog
Run Visual Studio and create a new ASP.NET Mvc4 Web Application project.
Note: In Visual Studio 2013, ASP.NET MVC 4 Web Application template is located under Web\Visual Studio 2012. You can upgrade to ASP.NET MVC 5 using NuGet after ASP Security Kit is installed in the project.
Choose basic as the template when creating ASP.NET Mvc project for ASP Security Kit
Choose basic as Mvc project template. Since ASP Security Kit gives you models, controllers and views necessary for registration, login and much more, ‘Basic’ is the ideal template to install ASP Security Kit to get up and running immediately.
NuGet Package Manager Console
Open Package Manager Console (Tools > Library Package Manager > Package Manager Console), and make sure the selected project in the console toolbar is the Mvc project and not the test project (if you have created one).
Change execution-policy for NuGet Powershell session
Run the following command in the console (hint: you can copy and paste it) and press y to confirm. Make sure that the command did not throw any error.
Set-ExecutionPolicy Bypass -Scope Process

Note: By executing the above command we are instructing PowerShell (the execution engine for Package Manager Console) to run scripts that will install ASP Security Kit without complaining about signing ETC. We’ll reset this instruction as soon as ASP Security Kit is installed in step 7.

Type install-package ASPSecurityKit and hit return to begin downloading and installing the package
We are all set; it’s time to install ASP Security Kit! Run the following command in the console (hint: you can copy and paste it)
Install-Package ASPSecurityKit
    
Sign in with your ASPSecurityKit.net credentials
This will pop up ASP Security Kit installer GUI which will prompt to login. Please provide your credentials that you got after purchase (these are the same you use to sign in on this site). If you haven’t received your ASPSecurityKit.net account credentials, let us know!
Select Package Options dialog. Choose the package, a theme and specify other settings you prefer for installing ASP Security Kit in your project
Once you sign in successfully, ‘Select Package Options’ form appears. It will show the package in your subscription. Please choose the desired package, a theme for it and specify other settings available for the selected package. You may read the license agreement if you haven’t already before installing.
a message box stating that package installed successfully
Once done, click Install button. The GUI is closed and you are back on Package Manager Console. You will see the status As ASP Security Kit installer installs the package.
Once installation is complete, you will see a message box stating whether or not package installed successfully.
Reset execution-policy to what it was before
Reset the execution policy we set in step 4 above – Run the following command in the console (hint: you can copy and paste it) and press y to confirm.
Set-ExecutionPolicy RemoteSigned -Scope Process
    

What if I got an error?

Here are possible issues along with their resolution:

NuGet reported that project installed successfully but neithre I saw ASP Security Kit 'Sign in' prompt nore I could see any new files/binaries in my project.

  • Make sure you installed ASP Security Kit using Package Manager Console in Visual Studio and not by any other mean (including 'Manage NuGet Packages...' dialog or NuGet.exe command line). You can reinstall if you did not.
  • If you did install via console, make sure you followed this step before installing. You can reinstall if you did not.

How to reinstall?

ASP Security Kit Powershell installer can be executed multiple times in a project and it will override any files with the same name in the project. This way you can fix failed/partial installations. To run installation again, do the following:

  • Open the packages.config file found in your project folder.
  • Delete the xml node (tag name 'package') that specifies ASPSecurityKit as part of its id attribute.
  • Save (and optionally close) packages.config
  • Begin installation by following these steps

I got failed installation message from ASP Security Kit installer; what can I do?

No problem! ASP Security Kit installer logs diagnostic information in the file <packages>\ASPSecurityKit.<version>\logs.txt. Please mail this file to us at support@ASPSecurityKit.net and we'll help you troubleshoot the issue.

Sometimes, when you are installing ASP Security Kit in a project bound to a source control such as TFS, installation may halt without completion. You can attempt reinstall at least once and see if it finishes with a success message.

Create the Database

As stated here, ASP Security Kit comes preloaded with EF migrations and T-Sql scripts to get the database ready as soon as you install ASP Security Kit.
While you are in the Package Manager Console, run the following command (hint: you can copy and paste it).

Update-Database 

You will see messages something like ‘Applying code-based migrations: ….’. If all goes well, the last message you see is ‘Running Seed method.’

Creating the database using Entity Framework Migrations' update-database command

Application Configuration

ASP Security Kit has added some useful configuration settings that it uses for the application. You can have a look at them in the appSettings section in the root web.config. By default most are populated with default value or values you provided on ‘Select Package Options’ form during installation.

Following settings aren’t populated by default and are required for forgot/reset password flow to work:




The above settings are used by Mailer.cs class installed in your project under Infrastructure\Utils. Email and password settings are self-explanatory; the provider setting can take one of three values: Gmail, Outlook or Yahoo. The Mailer class is preconfigured to work with these popular mail providers; since you have the source with you, you can extend it to work with any additional provider you plan to use for your project.

Congrats, We are done!

Press F5/ctrl+F5 to run the application. Congrats for installing ASP Security Kit! You are going to absolutely love the secure, flexible and rapid development basis it provides. Features that earlier used to take days to complete can now be completed within hours and in some case, within minutes!