开发者

User signup (site.com/name) and preventing against path clash

Not sure how best to word this, b开发者_运维知识库ut let's say you have a site that allows users to have a profile at the root level of the app's path:

http://www.example.com/

...and let's say the site has certain root level pages:

/about

/privacy-policy

/contact

/terms-of-use/

etc.

What's the best way to prevent users from creating usernames that clash with those paths, and what's the best way to setup the routing for this? The default routing in MVC will handle your typical controller/action/id layout. So, I'm guessing it should hit the specifics first, and then check against the profiles. How to best accomplish this?

Thanks all!


There are various ways to approach this. One is to use HandleUnknownAction for the profiles. You can also use reflection to get the list of non-profile actions.


Simply request the route for a uri based on the username. Phil Haack I believe has code to unit test routes based on a uri. I have some code for that I will edit after I get back if you don't see it on his blog.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜