So far, i don\'t think ViewComponent solves that neither does TagHelper. Is there any replacement to this? Something that takes parameters and retu
You can easily replace that "feature" with a ViewComponent (and a TagHelper if you want). ASP.NET Core is much more friendly to web designers, and the ViewComponents allow you to write HTML without any (weird to most) razor code.
For example:
Create a SayComponent : ViewComponent class:
public class SayComponent : ViewComponent
{
public void Render(string message)
{
return View(message);
}
}
Create a View file under Views/Shared/Say/Default.cshtml with just
@model string
Message: @Model.
And call it:
@await Component.RenderAsync("Say", "some message")
For a better experience, add this to your _ViewImports.cshtml file:
@addTagHelper *, YourSolutionName
And then you can use it as a tag helper: