Parse Url in C#.NET

Regex pattern = new Regex("(?
http(s)?|ftp)://(?([A-Za-z0-9-]+\\.)*(?[A-Za-z0-9-]+\\.[A-Za-z0-9]+))+((:)?(?
[0-9]+)?(/?)(?
(?[A-Za-z0-9\\._\\-]+)(/){0,1}[A-Za-z0-9.-/]*)){0,1}");

ya da

string url = "http://my.domain.com:8000?arg1=this&arg2=that";
System.Uri uri = new System.Uri(url);

// port bilgisi
int port = uri.Port;

// host adı (my.domain.com)
string host = uri.Host;

// protokol bilgisi
string protocol = uri.Scheme;

// saf url
string cleanURL = uri.Scheme + "://" + uri.GetComponents(UriComponents.HostAndPort, UriFormat.UriEscaped);
Category: Microsoft .Net, Yaptım
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>