Search For

Get Referrer URL

Flag Hide Line Nos
Flagging a Snippet, takes the snippet to Moderator Attention;

C# Program to find the visitor referrer URL, it can be used in ASP.NET or RAZOR to find the source location of the user.
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Web;
using System.Text.RegularExpressions;
namespace forgetcode
    class Program
        static void Main(string[] args)
             Uri referrer = HttpContext.Current.Request.UrlReferrer;
            if (referrer != null)
                string original = referrer.OriginalString.ToLower();
                Console.WriteLine("Visitor Came From "+original);
Vote! You feel this code is working like charm ? Go a head Login and Press up arrow.
Didn't work ?, press down arrow and let us know the error in comments


  • stevemannar
    You can retrieve exact url using URI Uri myUri = new Uri(""); string host = myUri.Host; full source steve
  • We donno you ! Login or Signup to make a Comment