Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello
I have a question about facebook url
you see www.facebook.com/[ProfileName]
how facebook make this?
I mean ProfileName is a dynamic name
How can I create it in ASP.NEt(C#)?
Is it a subdomain or a folder? if they are how can I create without subdomain or folder?
Thanks a lot
Posted

1 solution

It is never a subdomain. The subdomain comes from left, and upper-level domain names stay on right, but before '/'. For example, "facebook.com" could have subdomains "software" and "resources" the full domain names would come in URLs as "software.facebook.com" and "resources.facebook.com" (no, such subdomains do not exist), along with the default "www.facebook.com".

Actually, every part of URL that comes on right of the domain name (optionally with :port) is interpreted solely by an HTTP server and does not have to be anything related to the directory structure on the server host. There are different ways to provide the effect of dynamic URL you want. With ASP.NET, it can be done using URL rewriting techniques.

You can learn them from this article:
http://msdn.microsoft.com/en-us/library/ms972974.aspx[^].

[EDIT]

Another approach is ASP.NET Routing. Please see:
http://msdn.microsoft.com/en-us/library/cc668201.aspx[^],
http://msdn.microsoft.com/en-us/library/cc488545.aspx[^].

To compare URL rewriting with routing, please see:
http://msdn.microsoft.com/en-us/library/cc668201.aspx#aspnet_routing_versus_url_rewriting[^].

[END EDIT]

This is pretty much all you need to know to implement it with ASP.NET. For a record, different server-side technologies offer very different means of producing the similar server behavior.

—SA
 
Share this answer
 
v6
Comments
Tech Code Freak 29-Feb-12 3:55am    
5up!
Sergey Alexandrovich Kryukov 29-Feb-12 4:27am    
Thank you.
--SA
SinaNadi 29-Feb-12 13:44pm    
Thanks a lot for your answer
I think I couldn't say my problem correctly
I have several users in my website
I want every user have a profile page
the format of profile page is like this: www.mydomain.com/Profile.aspx?ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
for example: the profile name of that user is: sina
I want to make the url short like this:
www.mydomaincom/sina
what shoul I do?
Thanks a lot
Sergey Alexandrovich Kryukov 29-Feb-12 15:43pm    
Why not? You just did not share with me your purpose, but this if fine. You still have the same two options: 1) static URLs mapped to directory structure as by default, which you can update from time to time (as new users are introduced to the system); 2) dynamic URLs using URL rewri0ting.

Let's assume the names of your users are unique (otherwise you could not serve them). You could create subdirectories under your site's root directories, so new URLs with new content would appear as new user comes.

Or, you can use URL rewriting which would dynamically add URLs per users without the actual change in directory structure on the server's host. Why not? This is really the way to go. Just learn how to do it from the article I referenced above.

If you are finally convinced, consider accepting this answer formally (green button) -- thanks.
--SA
Sergey Alexandrovich Kryukov 29-Feb-12 21:27pm    
See also my updated answer, after [EDIT]
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900