views:

113

answers:

3

I'm new to ASP.NET MVC and all tutorials, samples, and the like I seem to find are very basic.

Is it possible (and if yes, a good design) to have routes like so: .../Organization/10/User/5/Edit .../Organization/10/User/List

In other words; can the urls mirror your domain model?

+1  A: 

Possible, yes, with a route something like:

"~/Organization/{orgId}/{Controller}/{id}/{action}"

Whether it is a good design or not I couldn't say for sure, only that it seems rather complicated to me.

If you have multiple User tables, one for each company, it might make some sense.

Garry Shutler
+1  A: 

Unless there is absolute necessity, keep routes decoupled from object model relations. Otherwise you will have to rewrite routes on every change in model.

Ihar Voitka
A: 

"If you have multiple User tables, one for each company, it might make some sense." Why only then?

"~/Organization/10/User/5/Edit"

... gives me the organization context at all times.

I didn't say so in my first question, but I've written an action filter that authorizes according to the rule that the logged on user must belong to the organization of the current action (hence not being able to see/edit/whatever user(s) of another organization).

I'm not saying that it's the best solution, but if not implementing this cross-cutting concern (aspect) as an action filter knowing the org id (via the action params), how would you solve the authorization issue elegantly?

As I initially stated, I'm new to the world of MVC and very excited about the answers.

Martin R-L
That's a whole other question all together and imo a very good one. Why don't you ask that one separately?
Garry Shutler