The type or namespace name ‘Hosting’ does not exist in the namespace ‘Microsoft.AspNetCore.Razor’

Current setting




There was an error running the template C:\Users\JeanB\.nuget\packages\microsoft.visualstudio.web.codegenerators.mvc\2.2.1\Templates\ControllerGenerator\MvcControllerWithContext.cshtml: Template Processing Failed:(4,47): error CS0234: The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)
(20,41): error CS0234: The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)
   at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.b__6_0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
   at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)

Solution

In order to resolve this issue I had to add the following package to the project.

Install-Package Microsoft.AspNetCore.Razor -Version 2.1.1

Leave a Reply

Your email address will not be published. Required fields are marked *