问题
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