Note that there are some explanatory texts on larger screens.

plurals
  1. POImplementing a Custom Identity and IPrincipal in MVC
    primarykey
    data
    text
    <p>I have a basic MVC 2 beta app where I am trying to implement a custom Identity and Principal classes.</p> <p>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.</p> <p>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: </p> <pre><code> [ &lt;%= Html.ActionLink("Log Off", "LogOff", "Account") %&gt; ] </code></pre> <p>If I pull this out it then fails on a different "Html.ActionLink" line of code.</p> <p>The error I receive is:</p> <blockquote> <p>An exception of type 'System.Runtime.Serialization.SerializationException' occurred in WebDev.WebHost40.dll but was not handled in user code</p> <p>Additional information: Type is not resolved for member 'Model.Entities.UserIdentity,Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.</p> </blockquote> <p>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.</p> <p><strong>UPDATE:</strong> 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. </p> <pre><code>GenericIdentity ident = new GenericIdentity("jzxcvcx"); GenericPrincipal princ = new GenericPrincipal(ident, null); Context.User = princ; </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload