下面是文件结构
我在Pages文件夹下具有默认的索引页,其布局为 _LayoutHarman.cshmtl
代码:Pages / Shared / _LayoutHarman.chtml
标题菜单:在这种情况下,页面位于subfolder.ie类别文件夹中
<a asp-route-cat_slug="electronic" asp-page="./category/Index">Electronic</a>
<a asp-route-cat_slug="beauty-care" asp-page="./category/index" >Beauty Care</a>
<a asp-route-cat_slug="toy" asp-page="./category/index" >Toy</a>
页脚菜单:页面位于根文件夹
<a asp-page="./Contact" >Contact</a>
<a asp-page="./terms" >Terms</a>
<a asp-page="./privacy" >Privacy</a>
代码:Pages / category / Index.cshtml
@page "{cat_slug?}/{pageIndex:int?}"
@model bList.Pages.category.IndexModel
@{
}
<nav aria-label="Page navigation example">
<ul class="pagination text-center">
@if(Model.prev_no!=0){
<li><a asp-page="category" asp-route-cat_slug="@Model.cat_url" asp-route-pageIndex="@Model.prev_no"> Previous</a></li>
}
@if (Model.no_more_record != "YES")
{
<li><a asp-page="category" asp-route-cat_slug="@Model.cat_url" asp-route-pageIndex="@Model.next_no">Next</a></li>
}
</ul>
</nav>
下一个/上一个按钮在此处生成网址,如下所示
https://localhost:8080/category/toy/1
https://localhost:8080/category/toy/2
https://localhost:8080/category/toy/3
分别取决于所选类别
问题::当我访问类别页面并单击上一个或下一个按钮,然后尝试单击链接联系方式,条款,隐私权时>即(在_LayoutHarman.cshtml上)或标题菜单上,然后href变为空白。
编辑者之一
代码:在_LayoutHarman.cshtml
HeaderMenu:
<a href="./category/toy" >toy</a>
页脚菜单
<a asp-page="./Contact" >Contact</a>
<a asp-page="./terms" >Terms</a>
代码:在Category / Index.html页面上
<a href="/category/@Model.cat_url/@Model.prev_no">Prev</a></li>
<a href="/category/@Model.cat_url/@Model.next_no">Next</a>
现在点击下一步/上一步按钮,标题菜单生成的网址为 https://localhost:44382/category/toy/category/toy因此出现错误页面。但对于页脚菜单,接触/术语/隐私可以正常工作
答案 0 :(得分:1)
我确实重现了您的问题,您需要在delete the point(.)
的{{1}}属性中asp-page
。
更改如下:
_LayoutHarman.cshmtl
您无需在<a asp-route-cat_slug="electronic" asp-page="/category/Index">Electronic</a>
<a asp-route-cat_slug="beauty-care" asp-page="/category/index" >Beauty Care</a>
<a asp-route-cat_slug="toy" asp-page="/category/index" >Toy</a>
<a asp-page="/Contact" >Contact</a>
<a asp-page="/terms" >Terms</a>
<a asp-page="/privacy" >Privacy</a>
中添加asp-page="category"
,只需在此页面中删除此属性即可。
这是我的测试结果:
答案 1 :(得分:0)
您真的需要所有这些额外的服务器端处理吗,asp-route-cat_slug asp页吗? 您不能只使用普通的老式HTML超链接吗?至于动态参数,也许您只能设置它们...
<a href="/category/toy/@Model.GetCategoryID">View category</a>
只是一个思考的想法...
欢呼