jao
jao

Reputation: 18620

Cannot add view to ASP.NET MVC 5 project

I'm trying to add a view to an ASP.NET MVC 5 project in Visual Studio 2013, but the Add button is greyed out.

vs 2013 cannot add view

Upvotes: 14

Views: 14999

Answers (4)

Glenn Gordon
Glenn Gordon

Reputation: 1446

The default installation of Visual Studio was missing some required elements. When I chose ASP.NET and web development, the following options were not selected on the right side of the page.

  • .NET Framework project and item templates
  • NET Framework 4.6.2-4.7.1 development tools
  • Additional Project templates (previous versions)
  • .NET WebAssembly build tools

(I found this on the Microsoft web site Microsoft Developer Resources (in spanish!) enter image description here

Upvotes: 32

Gülüm
Gülüm

Reputation: 30

You should create a controller first, then it will create a View folder automatically. Try to right click that file then click create new view. Also Copy might be a specific name, you may need to change that name.

Upvotes: 0

d219
d219

Reputation: 2845

Different from the OP issue (as I'm on VS2017) but in case anyone else comes to this question when they've made the same (basic) error as me...

It took me a few minutes to realise that if you type in a new Model class (as seen below) then this is not what the UI wants; it requires you to select an existing Model from the dropdown. Once I created the model and then selected it 'Add' was enabled.

enter image description here

Upvotes: -2

MartinDotNet
MartinDotNet

Reputation: 2575

I got this for ages, all I did was upgrade the nuget packages for Mvc and it fixed it. I suspect that I had a mismatch of versions in the solution.

Update-Package Microsoft.AspNet.Mvc -Version 5.2.3

The version part is optional, but it should mean that all projects get the same version.

Upvotes: 1

Related Questions