WHAT'S NEW?
Loading...
Showing posts with label MVC. Show all posts
Showing posts with label MVC. Show all posts
Hiya,

Recently I faced this interesting resource from James Chambers, definitely worth to take a look at it.

James will guide you in how to create your own MVC web application using technologies as C#, Bootstrap, Razor and more.

All of them contained in your Visual Studio application.

Please, see here below a summary with the main topics of this 30 days course:


The 30 Day Breakdown

Warming Up

Enhancing Our Views

Exploring Bootstrap

Special Announcement!
Adding Some Sparkle
So, You’ve Got People Logging In
Wrapping Up With Some More Bootstrap
Thanks a lot James!


Here we go again with a new tutorial to show you how to create a customized login using MVC 4 with Microsoft Visual Studio 2010. In this post, I will try to explain you how to develop different views, controllers, models, one database and of course, how all these elements interacts between them.

I have used MVC in older posts but I did not expend too much time explaing you how it works. MVC bornt as a software design pattern for implementing user interfaces. It provides a very useful architecture which splits between: the user interface (View), the logic and bridge between the user and the data (Controller) and finally the data (Model). Although originally developed for desktop computing, Model View Controller has been widely adopted as an architecture for World Wide Web. MVC 5 is the last template version released by Microsoft, but there are not too much differents with version 4. For the views, we are going to use Razor (CSHTML), the Microsoft dynamic view engine released in 2010. It is a new way to create your interfaces easier to use than ASPX, here you can check the differences beteween them.

Here below I show you all the steps to have your own login app:

  • Create the solution in Visual Studio: first of all, we need to create our project in VS2010. If you can't find the ASP.NET MVC4 Web Application template as showed in the image below, probably you need to download from Microsoft site. Remeber you need Service Pack 1 of VS2010. Write a name for your project and press OK.

In the following window, select a Basic template, which contains an specific structure of MVC 4. The view engine should be Razor and optionally create a unit test project.

As my first post in this new blog I want to make something a little bit "different". For this reason, this post is about "one time password" (OTP) generation mixed with a little bit of Model View Controller (MVC). The idea for this post is to make an overview (with a little bit of code, of course!) over an authenticator that Google uses.
Most of you already would know about OTP, but if not, your are in the right place. A one-time password (OTP) is a password that is valid for only one login session or transaction. OTPs avoid a number of shortcomings that are associated with traditional (static) passwords. The most important shortcoming that is addressed by OTPs is that, in contrast to static passwords, they are not vulnerable to replay attacks. This means that a potential intruder who manages to record an OTP that was already used to log into a service or to conduct a transaction will not be able to abuse it, since it will be no longer valid. On the downside, OTPs are difficult for human beings to memorize. Therefore they require additional technology to work.
My application is basically a login form which uses username and an OTP provided by the server to login users. The OTP last 30 seconds, after this time, it will expire and the user will need to generate a new one. Now I am going to explain the different parts of my code to make easier your comprehension. First I start with a screenshot of the different program parts and the arquitecture:
  1. Controllers: Encryption.cs is the engine of the app and who generates the OTP password from the user id and a random number. LoginController.cs is the second most important part and is dedicated on handle the user inputs and the management of the information between the Login view and the model.
  2. Models: just User.cs class is needed to handle the user information (login, otp, otp creation date, logged)
  3. Views: UserGetOtp.aspx is the first view where the user writes his login name; UserLogin.aspx is shown to finish the login process with the OTP provided. Finally, after a succesful log process, the Account.aspx view, from the Private Area is shown.

Here bellow you can see the core of the application, the OTP generation method. This algorithm is explained in the point 5.4 of the RFC4226 (see references at the bottom):