.NET MVC Object reference error

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


.NET MVC Object reference error



I have a very simple starter .NET application with this method in my controller:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using SampleMVC.Models;
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace SampleMVC
{
public class TurtleController : Controller
{
// GET: /<controller>/
public IActionResult Index()
{
return View();
}

public IActionResult Detail( int id ) {
var turtle = new TurtleModel{ id = 1, title = "Pink Turtle" };
return View("Detail",turtle);
}
}



My Turtle Model looks like this:


using System;
namespace SampleMVC.Models
{
public class TurtleModel
{
public int id { get; set; }
public string title { get; set; }

}
}



and my view looks like this:


@page
@model SampleMVC.Models.TurtleModel;
@{
<p>tester @Model.title</p>
}



However I'm getting a Null pointer / Object reference error when trying to view the URL /Turtle/Detail/1. Wondering if you can point me in the right direction?


/Turtle/Detail/1









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

NhACCifMwUErT3,0n d9IHsK5ar,4k5GI,sMLf,hI76l2 QRCRkSXU8,e88cC5rPeR3S,8,2wzEB pG sfm3 u,uzPY CgG,W
GGhAMDolcsZqRQWgLCL7JJ Arne O6wzqx4,LveUy5Lp 2LOaZs6Z,g XE2RK4tLa,3dEdnrW,w3Rcqw F6

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham