I opened an existing ASP.NET MVC3 project that formerly worked just fine in a newly built machine with Visual Studio 2012 installed.
I'm now getting null exceptions in the following code. After a User logs in, the following code is then executed to perform page fragment-level access.
The null exception is thrown on the WebViewPage.User object. However, when in debug mode, I can actually inspect a real instance of the object (see image below)
public static class WebViewPageExtensions
{
public static bool HasAccess(this WebViewPage pg)
{
if (pg == null) throw new ArgumentNullException("WebViewPage is null");
if (pg.User == null) throw new ArgumentNullException("WebViewPage User is null");
return pg.User.IsInRole(User.ACCESS_LEVEL_A) || pg.User.IsInRole(User.ACCESS_LEVEL_B);
}
}
Note: this could be something with the way my environment is configured (web.config maybe?), but not really sure where to start. As it is, the code that this is happening on is the same code running in production and the former developer environment.
All the references are still referring to the ASP.NET MVC3 version of the framework running on the .NET 4.0 platform.

EDIT: Here's the callilng code from a Razer view:
@if (this.HasAccess()) {
<div>
HTML here
</div>
}
Any thoughts?