【问题标题】:RazorPages with filenames that include a hyphen cause IntelliSense to break文件名包含连字符的 RazorPages 会导致 IntelliSense 中断
【发布时间】:2018-04-01 23:09:54
【问题描述】:

当使用带有连字符的文件名的 RazorPages 时,它会导致 Visual Studio 的工具在有效代码上显示红色波浪线。

以下是我看到的一些常见错误:

"The name ViewData does not exist in the current context"
"The name TempData does not exist in the current context"
"The name Model does not exist in the current context"

例如,我的 RazorPage 名为 Contact-Us.cshtml(带有连字符)会出错

然而,我的页面 ContactUs.cshtml(没有连字符)会很好。

有谁知道如何解决这个问题?

【问题讨论】:

  • 我不知道这是一个错误还是设计强加的约束。每个 razor 页面都可以有一个名为 Contact-Us.cshtml.cs 的代码隐藏文件,类为 Contact-Us。这似乎不是一个有效的类名。也许错误消息可以改进,但这听起来像是设计不允许的。

标签: c# razor asp.net-core .net-core razor-pages


【解决方案1】:

我在 GitHub 上发现了该问题。 https://github.com/aspnet/Mvc/issues/6296

这是一个已知错误,将在 Visual Studio 15.5

的发布中得到解决

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-07
    • 1970-01-01
    • 2020-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多