102425074
102425074

Reputation: 811

Why the asp-controller no work in the form tag helper?

I followed the tutorial of https://www.youtube.com/watch?v=mU4hV50rkVE&list=PL6n9fhu94yhVkdrusLaQsfERmL_Jh4XmU&index=40

As the video showed, there is an asp-controller attribute in the form tag helper as below: enter image description here

However, I can't find it in my visual studio: enter image description here

Although I still type the attribute inside the form tag helper.
After it compiled, the tutorial showed the source-code in the browser: enter image description here

Meanwhile, there is mine. It is much more different from the tutorial:
enter image description here

I am using the VS 2019 16.2.4 and .net core 2.2. What's wrong with this. How can I solve this? Thank you.

Upvotes: 0

Views: 45

Answers (1)

Nan Yu
Nan Yu

Reputation: 27528

You can add below line in _ViewImports.cshtml to add TagHelper support :

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

The purpose of the _ViewImports.cshtml file is to provide a mechanism to make directives available to pages globally so that you don't have to add them to pages individually.

Upvotes: 2

Related Questions