Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Getting page URL without querystring in C#

  1. using System;
  2. namespace ForgetCode
  3. {
  4. public class MainClass
  5. {
  6.  
  7. public static void Main()
  8. {
  9. string url = HttpContext.Current.Request.Url.AbsoluteUri;
  10. url = url.Split(new[] { '?' })[0];
  11. Console.WriteLine(url);
  12. }
  13. }
  14. }


Example result:
Input: http://www.forgetcode.com/repo/content/?set=1
Output: http://www.forgetcode.com/repo/content/