title: How can I set a global variable in Razor Pages of ASP.NET Core?
body: <p>I wanna to check if the browser is IE and do something in razor page.</p>
  <p>I just made a function in razor page to do that.</p>
  <p>However, I think use the function to check if the browser is IE in every razor page is redundant. For independent user, I just need to check this only one time and set a global variable that <code>IsIE=true/false</code> . And other page will easily know that if it is IE.</p>
  <p>The question is how can I get/set a global variable in razor page?</p>
  <p>Thank you.</p>
  <p>————————————————<br/><br/>
  To @Neville Nazerane ,here is the function which to check if is IE:</p>
  <pre><code>@{
      Boolean IsIE = false;
      string UA = Context.Request.Headers[&quot;User-Agent&quot;].ToString();
      if (UA.Contains(&quot;Trident&quot;) || UA.Contains(&quot;MSIE&quot;))
      {
          IsIE = true;
      }
      else
      {
          IsIE = false; ;
      }    
      if (IsIE == true)
      {
         
      }
      else
      {
         
      } 
  }
  </code></pre>