问题描述
因为我必须使用依赖注入,所以我的网站标题使用布局页面中的视图组件呈现。
现在我需要在这个标题中添加一个部分,该部分应该在继承该布局但找不到如何设置的页面中设置
布局
<header>
@await Component.InvokeAsync("Intestazione",new {paginaGuida = RenderSection("PaginaCorrente",required : false).Value })
</header>
组件
public async Task<IViewComponentResult> InvokeAsync(bool utente= true,string paginaGuida = null)
{
Intestazioneviewmodel vm = null;
if (paginaGuida is not null && utente) {
vm = new Intestazioneviewmodel($"?paginaCorrente={paginaGuida}",await gestioneUtenza.GetUtenteCorrente());
return View(vm);
}
else
{
return View("SenzaUtente");
}
}
viewComponent 视图
<a id="help" class="far btn-menu-guida" title="Help" href="@("~/Guida" + Model.UrlGuida)">
<span>Help</span>
</a>
示例页面
@section PaginaCorrente {@((int)PaginaCorrenteGuidaEnum.Dettaglio)}
调用viewcomponent时paginaGuida
参数始终为空,而在示例页面中section写入的文本为数字
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)