例如,我需要能够执行诸如asp-route- {value}之类的操作,而不必向其传递值和数据。
不是将asp-route-country和asp-route-lang传递给每个链接
@{
string lang = ViewContext.ViewData["baseLang"]?.ToString();
string country = ViewContext.ViewData["baseCountry"]?.ToString();
}
<a asp-controller="Home" asp-action="About" asp-route-country=@country asp-route-lang=@lang>country and lang</a>
<a asp-controller="Home" asp-action="About" asp-route-country="" asp-route-lang=@lang> only lang</a>
<a asp-controller="Home" asp-action="About" asp-route-country=@country asp-route-lang="">only country</a>
我可以忽略设置会话中已经存在的viewData变量,我只能像这样创建自定义标签助手。
<a asp-controller="Home" asp-action="About" country-lang>country and lang</a>
<a asp-controller="Home" asp-action="About" lang-only> only lang</a>
<a asp-controller="Home" asp-action="About" country-only>only country</a>
有没有办法查看asp-route- {value}如何发挥其魔力或复制类似的功能?
谢谢