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

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

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

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.

Now run your application and get a appropriate message.

If you want to return different view Index action then you return view name like this.
public ActionResult Index()
{
return View("Welcome");
}
Now
add a Welcoe View in View/Home
folder and run application.

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.
Leave Comment