Asp.Net MVC Core 1.0-带有空白区域的锚点标记帮助器 [英] Asp.Net MVC Core 1.0 - anchor tag helper with an empty area
问题描述
我在该区域的一个页面中有一个名为Admin的区域,我想导航到位于该区域之外的视图,实际上它不在任何区域中,我可以通过HTML帮助器进行传递像这样空着:
I have an area called Admin, in one of my pages in this area, I want to navigate to the views that are located outside of my area, in fact it isn't in any area, with HTML helpers I could pass empty for that like so:
@Html.ActionLink(item.ArticleTitle, "Details", new { id = item.ArticleId,title=item.ArticleTitle.Replace(' ', '-'), Area = "" })
但是当使用标签助手时,传递空无效:
But when using tag helper, passing empty doesn't work:
<a asp-action="Details" asp-route-area="" asp-route-id="@item.ArticleId" asp-route-title="@item.ArticleTitle.Replace(' ', '-')" class="btn btn-default">Detail</a>
值得一提的是,我已经看到了这个问题 ,但我的问题特别是关于以一种将区域导航到当前区域之外的站点根目录的方式来指定区域的方法,并且我知道我可以使用普通的URL,但是我很好奇是否可以使用标记帮助程序来完成
Worth to note that I've already saw this question, but my question is specifically about specifying the area in a way that it navigates me to the root of the site, outside of current area, and I know I can use normal URL, but I was curious if it could be done with tag helpers.
推荐答案
对于ASP.NET RC2,应该可以使用asp-area=""
.而且我非常确定,即使没有指定区域,使用RC1也会回到区域之外.
With ASP.NET RC2 it should work to use asp-area=""
. And I'm pretty sure that with RC1 I got back outside the area even without specifying the area.
在GitHub上查看我的帖子: https://github.com/aspnet/Mvc/issues/4319
See my post on GitHub: https://github.com/aspnet/Mvc/issues/4319
修改
在我的GitHub帖子中:
From my GitHub post:
使用RC1,即使在一个区域内,以下链接也已呈现为到根的链接:
With RC1 the following link had been rendered as a link to the root, even within an area:
<a asp-controller="Home" asp-action="Index">Home</a>
使用RC2(我每晚都构建1.0.0-rc2-20270)时,此类链接相对于该区域呈现.这对我有用:
With RC2 (I had nightly build 1.0.0-rc2-20270) such links where rendered relatively to the area. This worked for me:
<a asp-controller="Home" asp-action="Index" asp-area="">Home</a>
这篇关于Asp.Net MVC Core 1.0-带有空白区域的锚点标记帮助器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!