在asp.net mvc中用于asp控制器或asp-action的智能感知

时间:2017-11-07 11:46:02

标签: asp.net-mvc intellisense

我刚安装了最新版本的VS 2017 with asp.net core 2.标签帮助程序intellisense适用于asp-for="FirstName"(其中FirstName是我的模型的属性),但它不适用于像{ {1}}或asp-controller ="..."

是否有任何方法(例如扩展名)为控制器/动作...名称提供intellisense以避免手动输入?

更新(更多信息):

例如,如果您将名为Customer的模型设为:

asp-action="..."

并在您的Index.cshtml中使用razor代码:

public class Customer
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public int Code { get; set; }
}

您将在@{ var myVar = "abc";} <input type="text" asp-for="@myVar" /> <label asp-for="FirstName">Name:</label> <input type="text" asp-for="FirstName" /> <a asp-controller="Home" asp-action="About">About</a> 中对FirstName进行智能感知,但对于类似属性asp-for="Firs..."asp-controller="Hom...则不会,而且它们都是紫色和粗体(作为TagHelpers)。

1 个答案:

答案 0 :(得分:1)

这是不可能的,主要是因为找到控制器 - 以及因此行动 - 是棘手的。控制器可以是很多东西:

  • 从BaseController继承的类
  • 带有Controller后缀的POCO类
  • 其他一些会议提供的
  • 其他在运行时定义的