Asp.net mvc 附加到ASP.NET MVC中的当前URL

Asp.net mvc 附加到ASP.NET MVC中的当前URL,asp.net-mvc,friendly-url,Asp.net Mvc,Friendly Url,我知道这可能很容易实现,但我在找到答案时有点困难。类似于Stackoverflow如何允许您继续使用标记深入问题,我正在尝试实现同样的功能。因此,我在MVC页面上创建了一个“标签”列表,如下所示: <%For Each item As myItem In ViewData("topTags")%> <li><%=Html.ActionLink(Html.Encode(item.tagName), "Index", New With {.tags = item

我知道这可能很容易实现,但我在找到答案时有点困难。类似于Stackoverflow如何允许您继续使用标记深入问题,我正在尝试实现同样的功能。因此,我在MVC页面上创建了一个“标签”列表,如下所示:

<%For Each item As myItem In ViewData("topTags")%>
    <li><%=Html.ActionLink(Html.Encode(item.tagName), "Index", New With {.tags = item.tagName})%</li>
<%Next%>


  • 我想这就是你想要做的:

    <%For Each item As myItem In ViewData("topTags")%>
       <li><%=Html.ActionLink(Html.Encode(item.tagName), "Index", 
          New With {.tags = Request.QueryString("tags") & "+" & item.tagName})%></li>
    <%Next%>
    
    
    

  • 就这样做了,而且非常简单。我有一个if-then检查request.querystring(“标记”)在循环中是否为空。还有一个问题,如何在没有HTML编码的情况下显示+符号,或者这只是一种不好的做法?我认为如果你在那里使用空格而不是+符号会更好。