Solved

MVC Add View coresponding the controller

Posted on 2014-02-18
1
321 Views
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

http://www.asp.net/mvc/tutorials/older-versions/getting-started-with-mvc/getting-started-with-mvc-part3.


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


thanks.
0
Comment
Question by:dshi15
1 Comment
 
LVL 23

Accepted Solution

by:
Ioannis Paraskevopoulos earned 500 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


Giannis
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now