How to use uri.GetLeftPart() to get Authority, Path, Query and Scheme from URL in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Uri uri = new Uri("http://seek4info.com/index.php?query=web+hosting");

                Console.WriteLine(uri.GetLeftPart(UriPartial.Authority));
                Console.WriteLine(uri.GetLeftPart(UriPartial.Path));
                Console.WriteLine(uri.GetLeftPart(UriPartial.Query));
                Console.WriteLine(uri.GetLeftPart(UriPartial.Scheme));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}


/*
run:
 
http://seek4info.com
http://seek4info.com/index.php
http://seek4info.com/index.php?query=web+hosting
http://

*/

 



answered Mar 10, 2017 by avibootz

Related questions

2 answers 300 views
1 answer 206 views
1 answer 184 views
184 views asked Mar 10, 2017 by avibootz
1 answer 221 views
221 views asked Mar 10, 2017 by avibootz
1 answer 293 views
1 answer 189 views
189 views asked Mar 10, 2017 by avibootz
...