How does Identity.GetUserId() finds the user Id?
<p><strong>Question</strong></p>

<p>How does <code>User.Identity.GetUserId()</code> finds the current user's Id?</p>

<p>Does it find the user Id from the Cookies, or does it query the database? Or any other methods?</p>

<p><strong>Problem</strong></p>

<p>For some reason, <code>User.Identity.GetUserId()</code> returns <code>null</code> when I add a valid <code>Bearer Token</code> to my Http request header and send the request to my controller's endpoint:</p>

<pre><code>// MVC Controller Action Method

[Authorize]
public HttpResponseMessage(UserInfoViewModel model)
{
    // Request passes the Authorization filter since a valid oauth token 
    // is attached to the request header.

    string userId = User.Identity.GetUserId();

    // However, userId is null!

    // Other stuff...
}
</code></pre>