Creating ASP.NET MVC 5 Application using Entity Framework 6 and Identity with CRUD Operations on visual studio 2015 Part-5

This is the part-5 of creating  ASP.NET MVC 5 application using entity framework 6.x and identity in visual studio 2015. This includes a overview of ASP.NET MVC with the project layout description. Also, how to add a controller and view in ASP.NET MVC project. If you have any query please feel free and post a comment right below, your query will be answered as soon as possible . Other part of series:
  • How to add a controller and view ?

    • ASP.NET MVC Overview

      •  MVC (Model-View-Controller) is a architectural pattern as well as design pattern which divides the application into three separate layers Model, View and Controller.ASP.NET MVC  is a replacement of web forms but in MVC there is no a page behind code.In MVC one controller has multiple views and one shared view can be used in multiple controller.So in the view there is simple html content or user interface material, In controller there are action methods  that renders the html.Model basically a logical part of application that communicates with the database entities.So basic diagram of MVC is as follow.
      • In ASP.NET MVC 5 default template each and every folder have its own purpose. So let's understand the basic purpose of folder in diagram given below.

    • Adding a Registration controller

      • :Learn how to create a  controller? Let's create a  Registration controller .Right click on the controller folder and go to Add Controller.
    • In Add scaffold window select the empty controller and click to Add button right below.
    • Enter the name of controller in pop-up window.
    • Your controller is created with default action method Index and you can see the same folder is created in the views folder.e.g
  • Adding a Patient view 

    • Right click on the Patient action result method and go to Add View.
    • View name and action result name should be same in the pop-up window  and in the template drop down you have multiple template option of binding a view with your model class.I will explain here only empty template if you guy's ask me to explain other template option then i will explain in the new post.Make sure reference script libraries and use a layout page is checked.Finally click on the add button.  
    • Your patient view is created with default patient title heading.Make sure your patient view tab is selected just like below in the diagram and then click on the run button. 
    • You will see the following output in the browser window with URL localhost:port#/Registration/Patient.
    • If you change the URL like this localhost:49693 and press the enter. You will see the following error if you deleted the HomeController and Home view folder.
    • Now just open RouteConfig.cs file from App_start folder and change the  route from Home controller to Registration and Index action method to Patient. After save just click on the run button.
    • Now you will see there is no error with root URL localhost:port# .

No comments:

Post a Comment

Creating ASP.NET MVC 5 Application using Entity Framework 6 and Identity with CRUD Operations on visual studio 2015 Part-9

This is the part-9 of asp.net mvc 5 series using entity framework and identity from scratch.In this tutorial you will learn how to bind a...