-
Notifications
You must be signed in to change notification settings - Fork 53
8) Server (WebApi)
The Server is a asp.net mvc solution. MVC is a world class open source web framework developed by Microsoft. I chose it because it is fast, scalable and written in C#. You should have a basic understanding of how to develop with this technology before you begin. I also recommend using at least Visual Studio 2013 as your IDE.
- http://www.asp.net/mvc/overview
- https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx
You will also need a webhost to host the solution on the world wide web. Most any host that supports windows and mssql will do. I have tested this package on cheap $2 a month hosting as well as Azure.
Lastly, the next iteration of MVC (vNext) will support hosting on Linux web servers. I will update the package when this is released.
The webserver has a number of dependencies. These must be loaded using nuget. Right click on the solution file in the solution view and select Manage Nuget Packages For This Solution. You will be prompted to restore missing packages. Once complete rebuild the package and any missing reference exceptions will be remedied.
In the root there a ql generation script : Foundation.sql. Running this script will generate the sql tables. You may run these scripts together if you wish to use a single database.
You will need to setup DB migrations. This is controlled by the GLobal.asax.cs file. By default it is set to "drop and recreate the database" every time it runs. You will need to replace this functionality in production.
There are a number of settings that must be configured in the web.config.
The Connection string AppDatabase defines how you connect to the database. By default, it is set to use the db file in the App_Data folder. In production you will need to point this to the ip address of your db server.
There are a number of appSettings, most of which you may ignore. I will point out the important ones.
- ResetExpiration : Hours that the User Recovery Token is valid.
- EnableDevelopers : Enables new developers to register. Turn this off in production.
- AesKey : Key used to encrypt user passwords. (AED 256)
- AdminPassword : Default password of Admin user (create on installation).
- AdminEmail : Default username / email of Admin user (create on installation).
- Mail : Settings for the email service.
Information for logging into your host's outgoing smtp mail server. For hosting on Azure I recommend using http://sendgrid.com as an smtp provider.
Now the application is setup and you are good to run and/or deploy the app.
The email system allows for send users email when they sign up, request a token and when they update their account info. This allows for two-factor authentication and enables users to manage their accounts without any interaction on your part.
There are three emails sent from the system: Welcome when the user first signs up. Token will send a validation token for when the user requests a change to their account's email or password. Update notifying the user of any change to their account's details.
You may customize these emails by uploading Email Templates. These templates support RAZOR syntax. Razor syntax is an HTMLesq markup language with support for injecting 'Model Values'.
Once the package has been downloaded and your templates augmented, please upload them to your application using in the Dashboard/Files sub menu.