2

I have the following code calling the default ASP.NET MVC html helper

@Html.LabelFor(model => model.PersonName, htmlAttributes: new { @class = "control-label col-md-2" })

that I have changed for my ASP.NET 5 project to

<label asp-for="PersonName" class="col-md-2 control-label"></label>

If I mistype PersonName I get a red line below the name however I can still build my project successfully.

For the HTML Helper I always use intellisense by typing model. so I can't misspell the name.

With the TagHelper I don't have this option as it is a string field.

Is there a way use the same intellisense with the TagHelper as I don't want to discover typing mistakes at runtime.

zoaz
  • 1,981
  • 4
  • 17
  • 28

1 Answers1

0

As part of a View, TagHelpers are not not compiled at compile time, only runtime. IE, until an HttpRequest is made. Then, the related View is parsed and injected into the HttpResponse by the Controller. No code in your View will prevent your project from building.

To accomplish this, you'll need to create a build action that will specifically compile your Views at compile time. Because of the change in project structure, there don't appear to be any resources available yet that accomplish this. You may want to start here in your research Compile Views in ASP.NET MVC

If you just need IntelliSense, beta8 already has it. Make sure you've installed the Beta8 Visual Studio Web Developer Tools

Community
  • 1
  • 1
cygnim
  • 1,985
  • 2
  • 16
  • 22