0
文字列を変換する方法です(この文字列はasp-route -...属性を含む)をhtml属性のリストに変更できますか?かみそりエンジンは、すべてのasp-route -...属性を使用して正しいURLに変換する必要があります。私は次のコードを持っていますが、うまくいきません。文字列をHTML属性に変換する
@{
var Attributes = ViewData["Attributes"] as Dictionary<string,string>;
var AttributeRoute = "";
@foreach (var key in Attributes.Keys)
{
AttributeRoute += "asp-route-"+key+"=\""+Attributes[key]+"\" ";
}
}
...
@AttributeRoute #Prints output (ex. asp-route-testkey="testvalue")
<a class='item' @AttributeRoute>test</a> #Doesn't print the list of attributes