asp.net mvc folder organization

Hi all,
I'm new on asp.net mvc 2.0. I have a simple question that seems to be a bit silly but acutally I don't know how to resolve this little issue.
MVC is driven by action rather than pages.
The default routing should be: controller/action/id
An example can be: http://www.foo.com/home/dosomething

What if I want to organize things in a different way?
Let's say for example I want my url like this:
http://www.foo.com/en/home/doSomething
or
http://www.foo.com/us/home/results/doSomething

What to do in this case?

Thanks
xtremerealityAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roshan DavisCommented:
I think you meant was selecting the page based on Culture in ASP. If that is what you meant, go through this link
http://msdn.microsoft.com/en-us/library/bz9tc508.aspx
0
jamesbaileCommented:
You need to map your own routes.

In your global ASAX file

add

routes.MapRoute("home_example","{country}/{controller}/{action}", new {controller = "Home", action = "DoSomething");

and create a method on your home controller

public ActionResult DoSomething(string country)
{
}

when ever you use /us/home/dosomething or /uk/home/dosomething the above method should be called with the relevant value in the country parameter.

the sky's the limit in how you use this, but remember that there is a potential performance penalty if it all gets too complex and there are loads of mapped routes.
0
xtremerealityAuthor Commented:
Thanks James my question is not necessary related with localization but more about routing in general,
If I'm understanding correctly, if I want this route:

http://foo.com/firstpart/secondpart/controller/action the only thing should be create this routes

routes.MapRoute("home_example","{firstpart}/{secondpart}/{controller}/{action}", new {controller = "Home", action = "DoSomething");

Is that correct?
If yes, this should not affect the real folder structure right? I mean I should have on VS this organization:
Controllers:
---------------->HomeController.cs
Views:
---------------->Home
------------------------->Index.aspx

and NOT

Controllers:
---------------->firstpart
---------------------------->secondpart
--------------------------------------------->HomeController.cs

And same thing with the Views?
0
jamesbaileCommented:
the folder structure of your controllers and views is independant of your routes so you can have either structure - I use the first which seems to make sense to me.

just remember that when you put something in {} in the route you will need to provide a corresponding action with the relevant parameters.

In your example above you would need to implement an action on your home controller called DoSomething with the following signature

public ActionResult DoSomething(string firstPart, string secondPart)

firstPart and secondPart don't need to be strings so you could have

public ActionResult DoSomething(int firstPart, string secondPart)

if it makes sense
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Frameworks

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.