How to find current user within model in asp.net mvc
<p>I have a table for messages and another table for messageviews.  I'm looking to show unread messages to an individual user.  With my message table, I've sent up a new field that looks to see if any messageviews exist for the current message.  If they do, then my Viewed bool should return true otherwise false(if they haven't viewed the message).  Everything works fine, except that I'm unable to find the currently logged in user with User.Identity.GetUser() as I normally would.  I've added the correct usings as well.  Is there some limitation within a model to restrict this type of call.  If so, how can I find the current user within a model?</p>

<pre><code>    public bool Viewed
    {
        get
        {
            ApplicationDbContext db = new ApplicationDbContext();
            //var _userId = User.Identity.GetUserId(); 
            var _userId = Thread.CurrentPrincipal.Identity.GetUserId();
            List&lt;MessageView&gt; m_List = db.MessageView.Where(u =&gt; u.UserId == _userId &amp;&amp; u.MessageId == O_MessageId).ToList();
            var count = m_List.Count();
            if (count &gt;= 1)
            {
                return true;
            }
            else
            {
                return false;
            }

        }
    }
</code></pre>

<p>Resolved:  Outside of a controller you can find the current user with this -</p>

<p>var _userId = System.Web.HttpContext.Current.User.Identity.GetUserId();</p>