How does Stack Overflow map its users' accounts?
I tried to figure out how it does, but I can't find an answer. If you see the links when you hover over an user, you'll see this "pattern":
/users/number/username For example: users/2136639/leomestizo (my profile).
My guess is (imagine that Stack Overflow is programmed with Java):
- SO stores a JSP page for each user (doesn't seem to be the answer. If there's more than million users, there will be more than a million JSP pages! Not automatized)
- SO has a servlet (without the MVC pattern) that sends the HTML based in the parameter send to it, for example if the servlet is called "ProfileServlet", it could have an anchor tag like this: profileServlet?username="leomestizo". I think this could be an answer, but why the URL is always /user/number/username ?
Sorry if this seems to be a stupid question. I'm student and I do my best.
user
part of the URL. The controller already knows which View template to use. There's a routing engine that deals with each part in the URL; it routes this particular URL to theUserController
, and specifies the UserID as a parameter to the handling function. More info about ASP.NET MVC and how it specifically works can be found at asp.net/mvc, if you're so inclined.POST URL --> Routing Engine --> Controller --> Controller Method --> Dynamically Generated View