DISQUS

Emad Ibrahim: Tricky Asp.net MVC URL Rewriting

  • Nik · 1 year ago
    I've done exactly this for a project. It isnt ideal in that if you have a live system, and you subsequently need to add controllers, you need to check that *existing* users havent already used that controller name.
  • Net framework programmer · 1 year ago
    hello,

    how i can route to main page without using MVC (We are using System.Web.Routing assembly)
  • Emad Ibrahim · 1 year ago
    @Nik, you are absolutely right which is why I force user names to be 4 characters or longer. This way, worst-case-scenario, I can create a 3 letter controller. Not ideal, but a workaround.
  • Emad Ibrahim · 1 year ago
    @Net framework programmer, I am not sure how to do that. I haven't used the routing library with non-MVC projects. Good luck and let us know what you find out.
  • Marco · 1 year ago
    @Net framework programmer,
    Read this http://chriscavanagh.wordpress.com/2008/03/11/a... for routing with Web Forms
  • danatkinson · 1 year ago
    Have you thought about what happens if you decide to create a controller which happens to be the same as a user's name?!

    I'm not sure this is a very future-proof way of working...
  • eibrahim · 1 year ago
    You are absolutely right but I have worked around that by forcing users to
    use usernames with 6 or more characters and I also keep track of a list of
    banned usernames in the config file e.g. administrator, account, etc...
    It is not perfect but it works otherwise, you will be stuck with URLs that
    look like /user/eibrahim instead of just /eibrahim