I upgraded my solution from MVC 4 to MVC 5 in Visual Studio 2012 using this tutorial. In the last step I removed the ProjectTypeGuid for MVC 4 from my .csproj
file.
Now the problem is that I don't see Add Controller, Add View in Visual Studio when I want to create new Controllers/Views.
I read this answer for MVC 4 so I know I need to get the correct ProjectTypeGuid for MVC 5 in order to regain that functionality. I was wondering if anyone knows what that is so that I can add them to my .csproj
file?
Create view from controller In MVC 5Open the “HomeController” >> Set cursor inside the Action Method >> Right click on inside the action method >> click on [Add View] as follow. Provide the view name and select the appropriate layout and click on the “Add” button as follows.
The other way of passing the data from Controller to View can be by passing an object of the model class to the View. Erase the code of ViewData and pass the object of model class in return view. Import the binding object of model class at the top of Index View and access the properties by @Model.
Controller - The "C" in "MVC" Moreover, controllers in Asp.Net MVC, respond to HTTP requests and determine the action to take based upon the content of the incoming request. By default, controllers are stored in the Controllers folder of the project.
The sample ASP.NET MVC application includes a controller named HomeController. cs located in the Controllers folder. The content of the HomeController.
Install the following items:
Then follow this tutorial to upgrade your MVC 4 project to MVC 5.
Finally make sure your project has the following ProjectTypeGuids:
<ProjectTypeGuids>
{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
</ProjectTypeGuids>
In MVC5 the option you're looking for might be hidden under the Add Scaffold menu option. See the release blog post for more information on MVC5 scaffolding.
Some information gathered from: http://forums.asp.net/t/1950055.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With