Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 497655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:48:08+00:00 2026-05-13T05:48:08+00:00

I have a basic MVC 2 beta app where I am trying to implement

  • 0

I have a basic MVC 2 beta app where I am trying to implement a custom Identity and Principal classes.

I have created my classes that implement the IIdentity and IPrincipal interfaces, instantiated them and then assigned the CustomPrincipal object to my Context.User in Application_AuthenticateRequest of the Global.asax.

This all succeeds and the objects look good. When I begin to render the Views the pages are now failing. The first failure is in the default LogoOnUserControl view on the following line of code:

 [ <%= Html.ActionLink("Log Off", "LogOff", "Account") %> ]

If I pull this out it then fails on a different “Html.ActionLink” line of code.

The error I receive is:

An exception of type
‘System.Runtime.Serialization.SerializationException’
occurred in WebDev.WebHost40.dll but
was not handled in user code

Additional information: Type is not
resolved for member
‘Model.Entities.UserIdentity,Model,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null’.

Is there some additional properties that I need to implement in my Identity in order to use a custom Identity in MVC? I tried to implement [Serializable()] in the Identity class but it didn’t seem to have an impact.

UPDATE:
I’ve tried 3-4 alternate ways of implemented this but still fails with the same error. If I use GenericIdentity/GenericPrincipal classes directly it does not error.

GenericIdentity ident = new GenericIdentity("jzxcvcx");
GenericPrincipal princ = new GenericPrincipal(ident, null);
Context.User = princ;

But this gets me nowhere since I am trying to use the CustomIdentity to hold a couple of properties. If I implement the IIdentity/IPrincipal interfaces or inherit GenericIdentity/GenericPrincipal for my CustomIdentity/CustomPrincipal it fails with the original error above.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:48:09+00:00Added an answer on May 13, 2026 at 5:48 am

    I figured this one out with a little help from the web 🙂 The trick is that you have to implement the ISerializable interface in your class that implements IIdentity. I hope this helps save someone else some time 🙂

    Class declaration:

    [Serializable]
        public class ForumUserIdentity : IIdentity, ISerializable
    

    Implementation for ISerializable:

    #region ISerializable Members
    
            public void GetObjectData(SerializationInfo info, StreamingContext context)
            {
                if (context.State == StreamingContextStates.CrossAppDomain)
                {
                    GenericIdentity gIdent = new GenericIdentity(this.Name, this.AuthenticationType);
                    info.SetType(gIdent.GetType());
    
                    System.Reflection.MemberInfo[] serializableMembers;
                    object[] serializableValues;
    
                    serializableMembers = FormatterServices.GetSerializableMembers(gIdent.GetType());
                    serializableValues = FormatterServices.GetObjectData(gIdent, serializableMembers);
    
                    for (int i = 0; i < serializableMembers.Length; i++)
                    {
                        info.AddValue(serializableMembers[i].Name, serializableValues[i]);
                    }
                }
                else
                {
                    throw new InvalidOperationException("Serialization not supported");
                }
            }
    
            #endregion
    

    Here is the link to the article that has more detail on the “Feature”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic ASP.NET MVC 3 app. I have a basic action that
i'm trying to implement a basic mvc pattern for a java web app project
I created a basic Spring MVC / JPA / Hibernate app. I am trying
Im new to MVC and EF. I have a basic app that lists info
I have an ASP MVC app that uses it's own custom authentication mechanism. However
I have a basic MVC pattern created in Java that uses the Observable/Observer class/interface.
I have a basic directory app that works fine except that it seems to
I have a basic Spring MVC controller that looks like this: @Controller public void
I have a basic 3 tier app Presentation/Web (ASP.NET MVC) Application Services (WCF, hosted
I have a very basic email submission form in my ASP.NET MVC 3 app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.