以下代码执行正常
@foreach (var item in Model.SubCategories)
{
<div class="item-box">
<div class="sub-category-item">
<h2 class="title">
<a href="@Url.RouteUrl("Category", new { SeName = item.SeName })" title="@item.PictureModel.Title">
@item.Name
</a>
</h2>
</div>
</div>
}
这也有效
@foreach (var item in Model.SubCategories)
{
<div class="item-box">
<div class="sub-category-item">
<h2 class="title">
<text>@item.SeName</text>
@*<a href="@Url.RouteUrl("Category", new { SeName = item.SeName })" title="@item.PictureModel.Title">
@item.Name
</a>*@
</h2>
</div>
</div>
}
但是当我想用简单的href属性编写相同的代码时,VS会忽略该行。我甚至无法在线上设置一个断点。难道我做错了什么?
@foreach (var item in Model.SubCategories)
{
<div class="item-box">
<div class="sub-category-item">
<h2 class="title">
<a href="@item.SeName" title="@item.PictureModel.Title" />
</h2>
</div>
</div>
}
答案 0 :(得分:2)
添加链接文字:
@foreach (var item in Model.SubCategories)
{
<div class="item-box">
<div class="sub-category-item">
<h2 class="title">
<a href="@item.SeName" title="@item.PictureModel.Title">@item.PictureModel.Title</a>
</h2>
</div>
</div>
}