I'm using Visual Studio 2017 to build a .net core mvc project.
When I add a view in this way: Right click folder -> Add View -> Add
Then the name "Layout" does not exist in the current context
Restart vs or build the project this error still exist.
However, If I add view in this way:
Right click folder -> Add New Items -> MVC View Page
the Layout can be recognized.
Is there any difference?
If you are using vs 2017 you have to add this code in new csproj which you created.
<PropertyGroup>
<OutputType>Library</OutputType>
</PropertyGroup>
Because When you create a new Web application, this gets set to the "Web" SDK:
<Project Sdk="Microsoft.NET.Sdk.Web">...</Project>
so the Web SDK imports additional tasks to allow design-time processing of Web resources, such as Razor views. Change the SDK in your plugin library to Web. after you build error should be vanished.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With