IntroductionThis article shows how to use view result in a Controller in MVC.Step 1Create a MVC project from the "Empty" template.Right-click on "Controllers" and select "Add" >> "Controller...".Step 2Select "MVC 5 Controller - Empty" to add an empty Controller.Click on the "Add" button.Step 3Name the Controller as in the following:Step 4Now we need to create a view.Right-click on "Index" and select "Add View...".Step 5Name the view and select "Empty (without model)" as the template.Click on the "Add" button.Step 6Add a title in the index page.Step 7ViewResult represents a class that is used to render a view by using an IView instance that is returned by an IViewEngine object. View() creates an object that renders a view to the response.Step 8Now we need to create a view.Right-click on "About" and select "Add View...".Step 9Name the view and select "Empty (without model)" as the template.Click on the "Add" button.Step 10Add the title in the about page.Step 11Add html.actionlink for about.cshtml.Step 12Run the project, click on the about link and you will see the about page rendered in the browser.<< Day 10 >> Day 12
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: