Error (active) CS0234 The type or namespace name 'Index1Model' does not exist in the namespace 'RazorPagesTutorial.Pages.Employees'
项目报错:CS0234
Severity Code Description Project File Line Suppression State
Error (active) CS0234 The type or namespace name 'Index1Model' does not exist in the namespace 'RazorPagesTutorial.Pages.Employees' (are you missing an assembly reference?)
可能的原因:
因为我新建Razor页面的时候,默认的文件名字是Index1.cshtml和Index1.cshtml.cs,但我修改了名字成Detail.cshtml和Detail.cshtml.cs
尝试的解决办法:
1.我准备全局搜索Index1,然后修改Index1。但我全局搜索没有找到,全局搜索的具体步骤为
ctrl+f
但是全局搜索没有找到
2.我准备rebuild项目,但是rebuild依然报错(错误一样)
解决办法
1.我删除了报错页面的所有代码,然后重新敲了第二行model的代码(我之前应该也没有敲错,但不知道原因)
@page
@model RazorPagesTutorial.Pages.Employees.DetailsModel
@{
}
2.下次可以试一试关闭Visual Studio,然后重启。