title: The best way to persist a unique id on browser?
body: <p>What is the best way to persist a unique id on a browser session in MVC.NET?</p>
  
  <p>Is there some session/cookie ID value by default?</p>
  
  <p>In my Global.asax, I could create a new Session["ID"] and use its ID property.</p>
  
  <p>There's got to be another way?</p>
  
  <p>I tried using</p>
  
  <pre><code>var session = HttpContext.Current.Session;
  UserResearch userResearch = new UserResearch();
  userResearch.SessionID = sesstion.SessionID.ToString();
  </code></pre>
  
  <p>But i get an error:</p>
  
  <blockquote>
    <p>System.NullReferenceException: Object reference not set to an instance of an object</p>
  </blockquote>
  
  <p>I need to pull initial browser and clicking research based on a user that hasnt logged in to anything, so i need some way to refer to them, hence the id.</p>
  
  <p>I could create a unique id on the sql end and store it in a session, just seems like there should be a more straight forward way.</p>
  
  <p>Is there a browser session id?</p>