开发者

ASP.NET MVC routes with username /username/section vs /section/username

I was just wondering which routing style most people would use to have a username with various sections using ASP.NET MVC 3?

/username/profile
/username/settings
/username/details

vs

/profile/username开发者_Python百科
/settings/username
/details/username

If the first style was chosen how would you handle the routes?


Given your reply in the comment I would structure it as

/Settings

/Profile

and

/Username

When a user goes to /Settings or /Profile they will only see their own details.

when they go to /Username they will see the users profile (be it their own or someone else's).

your Global asax will need the appropriate routes set up to make this work.


As @raklos asked in a comment, it really depends on how the application is structured. To me, the left-most parts of a URL are more important that those to the right.

So, in your top design, the User is the most important part, and each user has different sections of stuff.

On the other hand, in the bottom design, the sections are the important parts and for each section, you could look at that information for a particular user.

For me, the most natural feels like the top one, because the profile, settings, and details are going to be unique for each user, so the concept is that a user has the various sections, rather than each section having various users. It also would seem more flexible/natural for some users to have more/less sections than other users, rather than some sections having more/less users than other sections.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜