MVC 3 I can't add a new controller or view - asp.net-mvc-3

I have installed the MVC 3, but after I've created that project, if I want to add a new Controller or View but there is no item in the list. See the images below. What's wrong ?
The project's targer framework is of course .NET 4
I have that items installed:

It looks like you are trying to add MVC components to an ASP.NET Web project, rather than an ASP.NET MVC Web Project

Solved
the purpose was, when I've opened the .csproj file there were wrong ProjectTypeGuids. I've replaced them with the data from the empty project and now it is OK.

Related

Which Visual studio template to use for web-app. (Standard / MVC)

Having to select a template when creating a new project in Visual studio, which of the 2 should pick?("asp.net core web app" ...or... "asp.net core web app (model-view-controller)")
In order to try and discover the answer for myself, I'd have to create 2 different projects and compare the features and capabilities. If I knew what to look for, it might been easier.
if the on template is MVC, then what is the non-MVC actually then?
If I go for the one project, would I be able to convert to the other later then? (and vise versa)
The simplest explaination is: In asp.net core you work with web pages where each of the webpages (Razor pages) has a code behind file. In asp.net core web app (Model View Controller) your code behind is kind of centralised, in a controller file, and this code redirects to different view files. There is more to this than that. Furter explaination can be found on from page 12 of in this document: https://dotnet.microsoft.com/en-us/download/e-book/porting-aspnet-apps/pdf

Is it possible to customize the asp .net mvc 3 generated Views?

I've been using asp.net mv3 via vs 2010 for quite a while now, also the default views and actions generated when creating a controller are very helpful. However lately, i found it redundant to keep on adding the same stuff in the generate view, for example, i have to place "btn" class names on links and button, since im using a 3rd party css library. So, i was wondering if it was possible to customize the generated views so that i wouldn't have to add them anymore after generation of the view?
image --> http://i.stack.imgur.com/J8Aiz.png
Yes it's possible to customize the built in TT templates which used fot the scaffolding.
Here is a good how to: Modifying the default code generation/scaffolding templates in ASP.NET MVC
If you are more into scaffolding the MVC Scaffolding project could be also interesting for you.

Missing Scaffolding Options in ASP.NET MVC 3 Add Controller Dialog

I have downloaded and installed the release version of ASP.NET MVC 3 (File version: 1.13.113.0), Created a new project of type ASP.NET MVC 3 web application.
When I right click on Controllers folder=>Add Controller, The Add Controller dialog doesn't have any scaffolding option. It just contains a textbox for Controller name and a checkbox to add action methods for CRUD scenarios.
should I do anything to view the Scaffolding options (Template, Model Class, Data Context Class and View) in Add controller dialog box?
In the Web Platform Installer 3.0 you can find something called "ASP.NET MVC 3 Tools Update"
Install that one and you get the Scaffolding options and some other stuff.
Yes agreed it takes forever to install via web platform installer. Use link http://www.microsoft.com/download/en/details.aspx?id=1491 to download and install.
Make sure you have the lastest with the tool update.
http://www.asp.net/mvc
ASP.NET MVC 3 Tools Update can take a while, but it fixed it for me.
If you tell Web Platform Installer to update Visual Studio it will take basically forever, I had to force shutdown and try again just doing MVC 3.
Thanks Beijer.

How to make razor the default view engine in existing project

I upgraded an MVC 2 project to MVC 3. How can I set the default view engine to Razor on an existing project?
Edit: Sorry, I was rather unclear. I want to have Razor be the default type in the Add View dialog.
Short answer:
Change in global.asax to use both webforms and razor:
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
ViewEngines.Engines.Add(new WebFormViewEngine());
The Add View dialog should default to a Razor selection in the view engine combobox if your project has at least one Razor file already or if it has no Aspx files (i.e. a project with no view files at all). Are you not seeing that behavior?
There is a MVC3 Upgrade tool.
You can find the tool and the tutorial here:
http://blogs.msdn.com/b/marcinon/archive/2011/01/13/mvc-3-project-upgrade-tool.aspx
When you create a new view you can choose the viewengine but i don't know possibilities to set razor like default.

Why does the default ASP.NET MVC 3 project not use controllers?

Upon creating a new ASP.NET MVC 3 Razor site, there are 9 Account\*.cshtml files which seem to be views with the controller logic inserted at the top of the view in an anonymous code block. There is no account controller class.
Why is this? As I understood, the benefit of MVC was the separation of concerns of code & presentation. Does this imply that I should remove all of the existing files & re-implement the Authentication & Authorisation layers?
It seems odd that MS would ship the 'worst possible example' with their flagship web framework.
Thanks,
Jarrod
Edit: I was using the wrong entry point within visual studio to create the application (see my comment below). Thanks!
Hmm, something is not quite right on your end.
I just created a new ASP.NET MVC3 Web Application.
I do have a 'Controllers' folder with a proper AccountController as part of the project.
Are you using Visual Studio?
This is incorrect. Here's the default folder structure in the MVC3 Razor starter app:
As you can see, there are two controllers in the ~/Controllers folder.
Just to be clear, I started a new VS2010 instance, created a new MVC3 project, selected "Internet Application" and Razor as the view engine.

Resources