Alesto Vincent
Alesto Vincent

Reputation: 13

I can't add a strongly-typed view to MVC project in Visual Studio 2015

First of all, when I right click on the Action Result method name there is no option for creating a view, only "Go to view" even it doesn't exist.

I added a view to the folder by "Add" -> "MVC 5 View Page (Razor)", but in dialog window I can type only the name

How to create a strongly-typed view?

Upvotes: 0

Views: 453

Answers (2)

Alexander Taran
Alexander Taran

Reputation: 6725

In recent update to web developer tooling they re added this functionality for mvc5/4 projects. https://get.asp.net/

Upvotes: 1

R Day
R Day

Reputation: 972

You can use the @model directive to specify the type.

Example:

public class MyModel
{
    public string MyString { get; set; }
}

The view:

@model MyModel

<p>@Model.MyString</p>

http://weblogs.asp.net/scottgu/asp-net-mvc-3-new-model-directive-support-in-razor

Upvotes: 0

Related Questions