附加到 ASP.NET MVC 中的当前 URL
我知道这可能很容易实现,但我在寻找答案时遇到了一些麻烦。 与 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%>
这会生成类似 http://mysite.com/controller/index?tags=MyTageName
我有一个控制器方法,它采用 tagName 参数值,我们很好......在第一级。 我希望能够获取此处返回的视图,并针对上述代码中的每个标签,将新标签名称附加到 url 中。 我新生成的 URL 如下所示:
http://mysite.com/controller/index? Tags=TagNameIClickedBefore+TagNameInForEachLoop
希望这是有道理的......有什么想法吗? 编写我自己的 HTMLHelper? 我缺少 URL.namespace 中的神奇函数吗? :)
I know that this is probably something easy to implement, but I am having a bit of trouble finding an answer. Similar to how Stackoverflow allows you to continue to drill down into questions using tags, I am trying to implement the same. So, I have created a list of 'tags' on my MVC page that looks like this:
<%For Each item As myItem In ViewData("topTags")%>
<li><%=Html.ActionLink(Html.Encode(item.tagName), "Index", New With {.tags = item.tagName})%</li>
<%Next%>
This generates nice URLs that look like http://mysite.com/controller/index?tags=MyTageName
I have a controller method that takes the tagName parameter value and we are good to go...on the first level. I want to be able to take the view that is returned here and for each of my tags in the above code, append the new tag name to the url. My new generated URLs would look like:
http://mysite.com/controller/index?tags=TagNameIClickedBefore+TagNameInForEachLoop
Hope this makes sense...any ideas? Write my own HTMLHelper? A magic function within URL.namespace I am missing? :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想这就是你想做的:
I guess this is what you want to do :