articles

Home / DeveloperSection / Articles / Working with View in ASP.NET MVC

Working with View in ASP.NET MVC

Anonymous User4185 11-Feb-2015

Working with View in ASP.NET MVC

Hi everyone in this post I’m explaining about implementing of view in MVC 4.

In my previous post I’ll intruduced about URL Routing in MVC 4

Description:

The ASP.NET MVC Framework allows building a web application. Mvc is divided into three part Model, View, Controller. In this post I’ll explain about implementing view. The view role can be implemented in several ways. The popular view engines used in the ASP.NET MVC 4 Framework are the Razor view engine. If you want to learn more about Controller read my previous post Working with Controller.

Any application is stand on three piller

1.       Presentation layer (User Interface)

2.       Business Logic

3.       Data Access Layer

If you design user interface in mvc you should use View.

firstly create a MVC Application.

Open visual studio >> File >> New Project >> ASP.NET MVC 4 Web Application

Working with View in ASP.NET MVC

And give the application name and click ok after click ok open a window and you select project type Empty

Working with View in ASP.NET MVC

 

Now an empty project is buildup successfully fallowing folder structure is created.

Working with View in ASP.NET MVC

 

If you want to some message in well-formed then you add a view in View/Home folder and write appropriate message. Now you run your application that time our application generate a error resource cannot be found because when run application that time search default controller and default action if you want to change default value of controller and default value of action this is part of URL Routing if you want learn more about URL Routing read my previous post URL Routing in MVC4.

Now add a HomeController in Controller folder. And define a Index Action method folder structure is below.

Working with View in ASP.NET MVC

 

 

Now run your application and get a appropriate message.

Working with View in ASP.NET MVC

If you want to return different view Index action then you return view name like this.

publicActionResult Index()

{

     return View("Welcome");

}

 

Now add a Welcoe View in View/Home folder and run application.

Working with View in ASP.NET MVC

You can use Layout page in view as like master page. In my view all information is static. If you work with dynamic data in view then you add a model. In my next post I’ll discus about about model Working with Model.


Updated 07-Sep-2019
I am a content writter !

Leave Comment

Comments

Liked By