asp.net mvc - .NET MVC routing using attributes only -


does know how create route in .net mvc contains attributes only? code follows:

[route("{listingcategorydescription}/")]     public actionresult categorysearch(string listingcategorydescription)     { 

as can tell want url contain category. possible? or need hard code @ least 1 part of route?

many thanks.

are wanting category passed in @ root url? http://localhost/apples?

if so, work, collide other routes.

public class categoriescontroller : controller {     [route("{listingcategorydescription}")]     public actionresult index(string listingcategorydescription)     {         return content("you picked category: " + listingcategorydescription);     } } 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -