简体   繁体   中英

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

Not sure how best to word this, but 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM