ViewComponent Tag Wizards not working

I updated my main asp.net web application from 1.0.1 to 1.1.0, but the help tags for my view components do not work:

<vc:login-form /> 

displays a tag. It works using the old syntax: @await Component.InvokeAsync (typeof (LoginFormViewComponent))

What am I missing?

package.json:

 { "title": "DevPortal.Web", "version": "0.1.0", "language": "", "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0", "type": "platform" }, "Microsoft.AspNetCore.StaticFiles": "1.1.0", "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", "Microsoft.AspNetCore.Mvc": "1.1.0", "NuGet.CommandLine": "3.5.0", }, "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final", "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final" }, "frameworks": { "netcoreapp1.1": { "imports": [ "dotnet5.6", "portable-net45+win8" ] } }, "buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true }, "runtimeOptions": { "configProperties": { "System.GC.Server": true } }, "scripts": { "prepublish": [ "bower install"], "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] }, "userSecretsId": "aspnet-DevPortal.Web-20161230052130" } 

I added this to _ViewImports.cshtml:

 @addTagHelper "*, DevPortal" 

and my build name is DevPortal.dll

 [ViewComponent(Name ="LoginForm")] public class LoginFormViewComponent: ViewComponent { public IViewComponentResult Invoke(LoginFormViewModel model = null) { if (model == null) model = new LoginFormViewModel(); return View(model); } } 
+6
source share
2 answers

In this case, the problem was also with a parameter with a default value. This issue is tracked on github, but ViewComponents cannot currently have parameters with default values.

This should work:

 <vc:login-form model="null" /> 
0
source

Old question, but had the same problem.

According to this link, it seems that _ViewImports or _GlobalImports not applied automatically inside ViewComponents . Try adding the @addTagHelper line in the ViewComponent .

0
source

Source: https://habr.com/ru/post/1262305/


All Articles