19578

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

Question:

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

<blockquote>

/Tags/Linq

/Tags/SqlServer

/Tags/MVC

</blockquote>

That Tags is constant name and after that in the URL is tag name.For example like <a href="http://weblogs.asp.net/scottgu/Tags/Linq" rel="nofollow">ScottGu's Blog </a>

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.

Answer1:

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.

Recommend

  • How do I create an Alias for a page URL?
  • Html table layout when binding with asp.net C# repeater
  • Jquery and Intellisense in VS 2008 with hotfix and SP1
  • Sending Mail from Windows Azure Service, using Godaddy SMTP [closed]
  • Can I combine several select queries in .net so they are returned in 1 batch?
  • Rows to Columns using Sql Query
  • Hibernate reverse engineering - mapping a table to Java enum
  • Rewrite part of javascript with C#
  • Routing in WCF data services
  • Grails/Roo for a .Net developer
  • Mod rewrite redirection to another domain if file not exist
  • How to bind comma separated list of values to List
  • How to write string.Contains(someText) in expression Tree
  • What do I do with this error when I run tests in rails?
  • Getting errors while using neuralnet function
  • Zend Framework + Doctrine1.2 project structure with more modules
  • Many to Many in Linq using Dapper
  • Multiple Left Join LINQ-to-entities
  • File extension of zlib zipped html page?
  • Mixing WebForms and MVC: What should I do with the MasterPage?
  • Exception creating JSON with LINQ
  • NUnit 3.0 TestCase const custom object arguments
  • Linq Merge lists
  • Loading .coffee files via a view in Rails
  • Webgrid not refreshing after delete MVC
  • Time complexity of a program which involves multiple variables
  • MVC3 Razor - ListBox pre-select not working
  • NHibernate Validation Localization with S#arp Architecture
  • Get one-time binding to work for ng-if
  • HTML download movie download link
  • Volley JsonObjectRequest send headers in GET Request
  • Importing jscolor library in angular 2
  • Circular dependency while pushing http interceptor
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Comma separated Values
  • AngularJs get employee from factory
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • JaxB to read class hierarchy
  • Easiest way to encapsulate a HTML5 webpage into an android app?