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

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

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