【问题标题】:How to use XSD Schema with Visual Studio Intellisense on ASP.NET MVC View如何在 ASP.NET MVC 视图上将 XSD Schema 与 Visual Studio Intellisense 结合使用
【发布时间】:2016-03-16 10:07:47
【问题描述】:

我想在手动编辑 ASP.NET View .cshtml 文件时在 Visual Studio 中使用 XSD 架构,这样我就可以访问 Intellisense 功能来访问 XSD 中描述的标记和属性。要输出的文件是用于控制嵌入式设备的 XML 文件。

这可能吗?如果是这样,怎么做?

是否有其他工具或其他方法可以做到这一点?

【问题讨论】:

    标签: c# asp.net xml asp.net-mvc xsd


    【解决方案1】:

    我解决这个问题的方法如下:

    1. 从 Visual Studio 解决方案资源管理器中,找到 .cshtml 文件。右键菜单 -> 打开方式... -> XML 编辑器。
    2. Visual Studio 主菜单 XML -> Schemas.. 找到或添加所需的 .xsd 架构文件。
    3. XML Intellisense 可能不适用于根对象之前的 Razor 标记,例如。 @使用,@模型。要解决此问题,请使用 <?ignore...?> 块,这将允许 XML 标记正确解析并且对 Razor 处理没有影响。参考:https://stackoverflow.com/a/14650451/3803219

    示例

    <?ignore This notation allows the "Intellisense XML autocompletion" to work
        @using...
        @model...
    ?>

    【讨论】:

      猜你喜欢
      • 2015-04-20
      • 2017-03-24
      • 1970-01-01
      • 2020-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-17
      • 1970-01-01
      相关资源
      最近更新 更多