In razor views I can access model state object:
@ViewData.ModelState
How can i inject and access ViewData
or ModelState
objects in razor TagHelper
? I tried the following, however the ViewData
and ModelState
are always null:
public class ModelStateTagHelper : TagHelper
{
public ViewDataDictionary ViewData { get; set; }
public ModelStateDictionary ModelState { get; set; }
public override void Process(TagHelperContext context, TagHelperOutput output)
{
}
}