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