title: Unable to cast object of type 'System.Security.Principal.WindowsIdentity' to custom class
body: <p>While developing in C# for ASP .net 4 in VS2013 using WebForms, I was implementing a custom security object that has been used through out of all my applications. With the upgrading from VS2010 to VS2013, I came to this error that bugged me so much....</p>
  
  <blockquote>
    <p>Unable to cast object of type
    'System.Security.Principal.WindowsIdentity' to type
    'CustomSecurity.BusinessObject.EmployeeIdentity'</p>
  </blockquote>
  
  <p>And the code location as follows:</p>
  
  <pre><code>public partial class _Default : System.Web.UI.Page  
  {
      protected void Page_Load(object sender, EventArgs e)
      {
          //This is where it fails 
          EmployeeIdentity employeeIdentity = (EmployeeIdentity)HttpContext.Current.User.Identity;
      } 
  }
  </code></pre>
  
  <p>This line of code worked in VS2010 but didn't work in VS2013. The code compiles but gives me this error during run time.</p>
  
  <p><strong>Things I have tried so far:</strong></p>
  
  <ol>
  <li>Converting the CustomSecurity.BusinessObject.EmployeeIdentity to .net 4 assembly</li>
  <li>Changed code to use Page.User and I still get the same error</li>
  <li>Read other posts in StackOverflow, no luck in finding an answer....</li>
  </ol>
  
  <p><strong>My Question:</strong>
  What are other suggestions that may resolve my issue?</p>