Sunday, 9 March 2014

4 Simple Steps to Follow for Developing Your First ASP.NET MVC5 Application


For accomplishing separation between different application components, Model-View-Controller is a great software pattern as it is considered the best choice for software apps. It is must that there should be clear separation between business logic and the user interface.

Accomplishing it is extremely easy with the help of MVC design that makes application more flexible to change. When it comes to ASP.NET MVC, it is one such framework that mainly based on MVC (Model-View-Controller) design pattern, and it can be used for developing web applications.

Microsoft has launched the latest version of its framework as MVC 5 that comes some amazing new features and boosting existing features also. When it comes to develop ASP.NET MVC5 application, one should follow below mentioned 4 easy steps that make their development process a lot easier:

  1. Developing MVC5 Project in Visual Studio 2013:

  • Firstly, developer needs to open Visual Studio Express 2013 for Web and develop “New Project” as File-->New Project.

  • Select “ASP.NET web application” template as shown in following figure. Developer should name the project as “MyFirstMVC5App", prefer location and press "OK" button.

  • Select MVC as template and again press “OK” button in next dialog.

  • All new ASP.NET MVC 5 project will be developed as follows as one can easily find the “Controllers”, “Models” and “Views” folder in solution explorer.

  1. Preparing a Model:

  • Developer should right click on “Models” folder and select “Add” and then “Class” to prepare a model.

  • Name the class as “Employee.cs”.

  • As we also discussed earlier that Model is the representation of data structure in Data Source that can assume this “Employee" class represents an Employee table in database with column as “EmpID", "EmpFirstName", "EmpLastName" and so on.

  1. Add Controller:

  • One should also right click on “Controllers” folder to add a controller to project and can select “Add” then Controller.

  • Select “MVC 5 Controller – Empty” from “Add Scaffold” dialog and press “Add” button as following:

  • One should name the controller as “EmployeeController” in next dialog and have to press “Add” as a new controller will be added to “Controllers” folder. Controller code generated will be as follows:

  1. Add a View:

  • When it comes to add a view, right click on newly developed “Employee” folder under views and selecting “Add” then MVC 5 View Page. Specify the name for the view "Index":

  • A new file with the name “Index.cshtml” will be added under “ Views->Employee" folder. I have added meaningful some text to this page.

  • Finally, developing a simple yet effective ASP.NET MVC 5 application has been created. To run the application, one should click CTRL+F5 that results will be follows:

Now, we are done with creating a simple ASP.NET MVC 5 application. To run the application, click CTRL + F5. At last, one should change the URL in browser from above to http://localhost:11517/Employee/ and press enter; still the output remains the same. If you are also looking to get ASP.Net website development, make sure to hire Asp.Net developer, who has years of experience in developing Asp.net industry.

No comments:

Post a Comment