Asp.Net (C#) MVC Routing - Trying avoid using the same controller in different places and think rout

Posted by sheefy on Stack Overflow See other posts from Stack Overflow or by sheefy
Published on 2010-05-07T12:05:37Z Indexed on 2010/05/07 12:08 UTC
Read the original article Hit count: 214

Filed under:
|
|

Hi Guys,

I'm currently building a site which has a bunch of main categories and in each category you can perform a search.

Basically, I want my addresses to work like this...

When the website loads (as in when someone goes to www.mySite.com) it will redirect them to the default category.

www.mySite.com/Category

Then when you search within a category, the results would come up in a page like the following.

www.mySite.com/Category/Search

I want to put everything in one controller and have one main view for the Category and one for the Search, I would then render these based on which category is currently being viewed.

Can this be done, maybe with routing? I don't want to have to create a different controller for each category as it's just duplicating a lot of the code.

Thanks in advance for your help.

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about routing