CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.faq_frequently_asked_questions Tags:
Item Type: NewsGroup Date Entered: 2/12/2007 6:48:04 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 1 Views: 90 Favorited: 0 Favorite
2 Items, 1 Pages 1 |< << Go >> >|
cis4life
Asp.Net User
how do you parse a subdomain out of the URL2/12/2007 6:48:04 PM

0

Hello,

 My question is simple, but I can't seem to find a clean and to the point answer.  I simply need to pull the subdomain string out of a url if one exist.

Example

http://cedric.mysite.com

How would I pull the string 'cedric' out of this? and also how can I tell (Programmically) if there is a sub domain?

Thanks,
Cedric

[email protected]
Asp.Net User
Re: how do you parse a subdomain out of the URL2/12/2007 8:40:39 PM

0

How do you define a subdomain?  Technically, in your example, cedric is a host name, not a subdomain.  http://www.cedric.sample.com/ would make cedric a subdomain, and the host www resides in the domain cedric, which is a subdomain of sample in the top level domain of com.

So, do you need the host or the subdomain?  Or the host name unless it's www?

In any case, there are plenty of string manipulation options to get you this.  Might start at:

http://aspnet101.com/aspnet101/tutorials.aspx?id=5

The most straightforward way might be to strip the frist seven characters (http://):

Dim strURL as String
Dim strDomain as String
strURL = "http://cedric.sample.com"
strDomain = strUrl.SubString(7)

Then split the result at the periods:

arrDomainParts = strDomain.Split(".")
Dim strHostname as String
strHostname = arrDomainParts(0)

Of course, don't count on my code being correct, I type poorly and sometimes forget the syntax...  :)

 Jeff


Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Google Hacking for Penetration Testers Authors: Johnny Long, ScienceDirect (Online service), Pages: 534, Published: 2007
Web Application Vulnerabilities: Detect, Exploit, Prevent Authors: Michael Cross, Steven H Palmer, ScienceDirect (Online service), Steven Kapinos, Haroon Meer, Igor Muttik, Ph.D., Roelof Temmingh, Pages: 460, Published: 2007

Web:
how do you parse a subdomain out of the URL - ASP.NET Forums how do you parse a subdomain out of the URL. Last post 02-12-2007 3:40 PM by [email protected]. 1 replies. Sort Posts: ...
Most efficient way to parse subdomain from request.url.host? - ASP ... I would like to retrieve the subdomain "only" from the URL so that I .... Given the choice between using Instr a few times to parse it out ...
Hosting Admin URLs on a Subdomain (Articles) | The Bakery ... Apr 13, 2007 ... As far as the code in the comment above, that's a good way to parse the subdomain out of the URL, but the way routes are generated seems a ...
Parse FTP url Hi all, does anyone know how I can parse an ftp url to retrieve the ... I can get out the following info server = subdomain.domain.com ...
Need to parse out domain name I have the need to parse out the raw domain name from a site URL. Just the domain name, and not any subdomains. ...

Using ASP:HyperLink to do a post-back to my Custom Control? How ... I'm wanting to use a DataRepeater to spit out a list of Company Name / HREF combinations, .... your permissions do not allow you do upload images in ftb ...
Execute javascript and perform postback from the same ASP.NET ... how do you parse a subdomain out of the url · formatting text · "unable to start debugging on the web server. you do not have permission to debug the ...
Using WebClient to download a file with a Proxy Server - ng.asp ... ... to url ... do you have a proxy server between your computer and the server? ... Proxy List can download and parse a fresh proxy server list from the ...






how is create run time divs and passing value in database?

asp.net 2.0 - accessing controls in the previous page

how to: build a dynamic gridview at runtime

javascript working in ie but not in firefox

how to improve website ranking google

send a mail with attachment

tracking items

re: smtp server and email faq

various compatibility and usage questions: vwd / visual studio 2005 / sql server express

about session & caching

how to find assembly in asp.net 2005

insert an apostrophe into a sql string

how to create file downloading facility in asp.net 2.0 ?

email cannot send by .net 2.0

source code to these forums?

dispose of an object

how can i create online-exam project in asp.net using c#?

searching sql database with stored procedure vs searching through a dataset

from email

to close the popup window after export.

whidbey: the new compilation model

creating excel file in asp.net

visual studio 2005 sp1, asp.net ajax 1.0 rc1 and .net framework 3.0

preventing a button from validating the form

asp.net 2.0: any good tutorial sites?

buttons do not submit anymore in ie

how to configure web service and web site for large files?

problems in componenetart datagrid paging

can i group a few textbox to validate together?

how to sort data into gridview

   
  Privacy | Contact Us
All Times Are GMT