MVC Add View coresponding the controller

Posted on 2014-02-18
Medium Priority
Last Modified: 2014-02-19
Hi Expert,

I couldn't "Add View" by right-clicking in the View portion of the code as shown below.

   public ActionResult Index()
   return View();

I can add view but not related my helloworldcontroller.

I followed this tutorial and I Used visual studio 2010 and MVC2


>>Let's now add a View template to our project that we can use for our Index() method. To do this, right-click with your mouse somewhere in the middle of the Index method and click Add View...

Question by:dshi15
1 Comment
LVL 23

Accepted Solution

Ioannis Paraskevopoulos earned 2000 total points
ID: 39869994
You can manually add a view:

In the Solution Explorer right click on the 'Views' folder.
Select 'Add'->'Folder' and name it 'helloworld'. The name of the folder should be the same as the name of the controller when you remove the word 'controller'.
Then right click on your newly created folder and seletc 'Add'->'View'.
Now, if you name your view 'Index' then you are good to go. You may name it whatever you like, but then you should have:

    return View("YourViewName");

Open in new window


Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In this post we will learn different types of Android Layout and some basics of an Android App.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Loops Section Overview

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question