Reputation: 1070
Hi I am facing following error while building an MVC core application.
Severity Code Description Project Line Suppression State File Error CS0246 The type or namespace name 'ErrorModel' could not be found (are you missing a using directive or an assembly reference?) JSViewer_Angular(Core) 86 Active C:\Users\user\Desktop\JSViewer_Angular(Core)\obj\Debug\net462\Razor\Pages\Error.g.cshtml.cs
Any ideas behind this error.
Upvotes: 4
Views: 17313
Reputation: 612
Maybe you have renamed project or moved around namespaces? Check in Pages/_ViewImports.cshtml if @using and @namespace are correct
Upvotes: 4
Reputation: 156
Check your namespaces in your project. I got this when I renamed my root namespace and project file and I forgot one reference in the _ViewImports.cshtml file.
Upvotes: 13
Reputation: 130
I had this error now, I only publish working app and make some minor changes and this error about 'ErrorModel' is missong shows up.. I work it with custom ErrorModel.cs added simple as possible:
public class ErrorModel : PageModel
{
public string Code { get; set; }
public void OnGet([FromQuery]int code)
{
if (code > 0)
{
this.Code = "Status Code: " + code;
}
}
}
And change of @if (Model.ShowRequestId) of on:
<h3>@Model.Code</h3>
Now its compiled without any errors.. But as I said.. don't know the cause of this error..
Upvotes: 0
Reputation: 21
I think you might have forgotten to add your model reference or directory to your assembly, or else there might be a problem with added references.
Upvotes: 0