Abhijeet
Abhijeet

Reputation: 13906

Asp.net MVC-4 Basic button click count page - Beginner

Using mvc-4 basic template I am creating a view with button a HTML button. Which upon being clicked will display. How many times this button has been clicked.

Created Model

ButtonTest.cs

namespace testmvc4basic.Models
{
    public class ButtonTest
    {
        public int clickCount { get; set; }
    }
}

Created View Strongly typed View

@model testmvc4basic.Models.ButtonTest

@{
    ViewBag.Title = "ButtonTest";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

ButtonTest


While Attempting to create Controller, with the dialog enter image description here

I get unsupported context type. What Am I missing, please ?

Upvotes: 0

Views: 1426

Answers (1)

testCoder
testCoder

Reputation: 7385

  1. If you have created Database Context, and needed context not appear in list in add controller dialog - try to build solution, and try to add controller again, your model class should appear.
  2. If you don't have Database context, and you still want to add controller using same template you need to create Database context class inherited from DbContext or Object context.
  3. Or if you don't want to use context you should choose another template without specifying any context

Upvotes: 1

Related Questions