c# - Access Shared Resources from Tag Helper -
i'm trying access shared resources in tag helper, doesn't return value resource file though know exists, resourcenotfound. use ihtmllocalizer access shared resources in of views , works fine should configured correctly.
tag helper:
[htmltargetelement("lc:buy-button", attributes = "product", tagstructure = tagstructure.withoutendtag)] public class buybuttontaghelper : basetaghelper { private readonly istringlocalizer<sharedresources> _localizer; public buybuttontaghelper(apphelper app, istringlocalizer<sharedresources> localizer) : base(app) { _localizer = localizer; } public override void process(taghelpercontext context, taghelperoutput output) { ......... base.process(context, output); } private string processhtml(string html) { string result = html.replace("{?productid?}", this.product.tostring()); result = result.replace("{?subscribetext?}", _localizer["subscribebuttontext"].value); return result; } [htmlattributename("product")] public int product { get; set; } = -1; }
solved installing nuget package microsoft.aspnetcore.mvc.localization
Comments
Post a Comment