Solved

MVC Add View coresponding the controller

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

791 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