Issue between HttpRequest.ServerVariables["http_user_agent"] vs HttpRequest.UserAgent
<p>I have this code:</p>

<pre><code>&lt;p&gt;
    &lt;b&gt;You are browsing this site with:&lt;/b&gt;
    &lt;% Response.Write(Request.ServerVariables["http_user_agent"]); %&gt;
    &lt;br/&gt;
    &lt;b&gt;Or with Request.UserAgent:&lt;/b&gt;
    &lt;% Request.UserAgent.Trim(); %&gt;
&lt;/p&gt;
</code></pre>

<p>The first one is shown correctly in the browser but the second one (<code>Request.UserAgent</code>) is not showing. Why? Also If I write the second one in the <code>Page_Load</code> method in the code behind it works fine. Why the second one works in <code>Page_Load</code> but not in the <code>p</code> tag. Also based on Microsoft and <a href="https://stackoverflow.com/questions/11472820/httprequest-servervariables-vs-httprequest-useragent-properties-vb-net">this</a> answer the both of them should be same:</p>

<blockquote>
  <p>In ASP.NET, you can access the Request.ServerVariables collection or use the new Request.UserAgent property to retrieve the HTTP_USER_AGENT header value.</p>
</blockquote>