Extend available properties of User.Identity – Asp.Net [web api]

Asp.net web api by default contains some pre configured fields that can handle the registration of a user in a web app. Some of them are Email, Password, Confirm Password and others. You can extend those properties and include your own for your purposes with the following procedure.

First of all you need to execute some commands in the package manager. You can find nuget package manager in Tools -> Nuget Package Manager -> PM Console 

The first thing to do is to enable Migrations

The you can go to Models\AccountBindingModels.cs and add your property to the class RegisterBindingModel. Also add the same property in the Models\IdentityModels.cs inside ApplicationUser class. For example lets assume you want to add a username in the registration proccess. For this purpose you can use the following line

Also include in the file.

The you must execute:

Those commands will run all the migration files and update the database schema to add a AppUserName column in your database.

Then update the registration action in Controllers\AccountController.cs to store AppUserName as well.

It was that easy. you can finally find AppUserName in your database.

SQL queries with PHP on MYSQL database – Azure

A few days ago i activated Azure for students through Dreamspark. I am very happy microsoft give those tools for free in students. After searching the options that are available for free, i found that i could use some mysql databases. As mysql is very common and frequently used, i created a database and wanted to add some data. Unfortunately i couldn’t find a tool for managing the database. As you may know most linux servers come with phpmyadmin pre-installed. So what about Azure?

There are many options for Azure.

  1. You can connect to your database with mysql commands using mysql command line tool.
  2. You can download a GUI tool and do the work (mysql workbench)
  3. You can use any php code to connect.

So here comes this github project with which you can connect on a mysql database that is stored in Azure.

See more details in the below pictures

First of all you must create a mysql database.

new_mysql

After you create the database you must press properties window to see the connection credentials. Those are: Host name, Database Name, Username, Password.

connection

Then you are ready to start using your mysql database. And here comes the PHPqAzure.

As you can see, after entering your credentials you can run your queries. Query result is returned after query is executed.

Example:

Create a test table.

 

create_table

Add some data

insert

And you are ready. You can see the result with a mysql GUI management tool like Mysql Workbench.

program_view

You can perform as many queries as you want. Make sure your queries executed successfully with the results tab.

If i enter something wrong then the result will inform me for that.

wrong-query

 

How to center UL with CSS – HTML

Ever wondered how to center a ul with css in a html page ?

And the result

Capture