Creating an ActionLink and MapRoute that there is a constant name in it

徘徊边缘 提交于 2019-12-25 06:14:25

问题


In my Asp.net MVC 5 (C#) project I want to create some links by @Html.ActionLink or every you know is better like:

/Tags/Linq

/Tags/SqlServer

/Tags/MVC

That Tags is constant name and after that in the URL is tag name.For example like ScottGu's Blog

In addition I want to pass a parameter such as Id but I don't want to show in the URL.

How can I do it?

And how should I write a suitable MapRoute for it?

Please help me.


回答1:


For example (don't forget to write it before default route):

routes.MapRoute(
     "Tags",
     "tags/{tagTerm}",
     new { controller = "Tags", action = "SearchTagResults" }
);

In addition (passing Id) use POST not GET.



来源:https://stackoverflow.com/questions/25234560/creating-an-actionlink-and-maproute-that-there-is-a-constant-name-in-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!