-
Notifications
You must be signed in to change notification settings - Fork 209
Description
I upgraded to the latest v8 update (8.0.114) and the razor tooling is a little wonky.
# create project
dotnet new razor -o Demo
# repurpose default index page as "products" page
cd Demo/Pages
mkdir Products
mv Index.* Products
In Pages/Products/Index.cshtml.cs
change namespace Demo.Pages;
to namespace Demo.Pages.Products;
All that does is convert the "default" page to a custom "products" page, and puts that in a dedicated namespace. That is the typical setup, and used to work - every feature had it's own directory and namespace, and the razor view would be able to identify the corresponding page model class, since it's in the same directory.
Now for the bug. Open the razor page Pages/Products/Index.cshtml
. The line @model IndexModel
will be an error:
The type or namespace name 'IndexModel' could not be found (are you missing a using directive or an assembly reference?) [CS0246]
The workaround is to add @using Demo.Pages.Foo
to every razor file.
Interestingly, the project compiles and runs without error, but our razor files are full of red squigglies.
Environment: .NET 8, VSCode, linux