markneustadt.com

CustomPrincipal and Serialization

Recently, I’ve been working on a project that relies on a backend business object layer.  The business object (BO) layer, requires authentication in order to be used.  For most of the systems, this is okay, but my project is to be used by end users.  We don’t need to authenticate the users… we need to authenticate the system.

This is easy enough using the CustomPrincipal object in Rocky Lhotka’s CSLA framework (which is also being used).  We simply create the CustomPrincipal and add that to the ApplicationContext.

The problem arises when I try to access the Request object.  Actually, it’s the Url property of Request.  When I try to access it, I get the following error.

‘Request.Url’ threw an exception of type ‘System.Runtime.Serialization.SerializationException’

Other developers in the shop are running the code without error.  What’s especially frustrating about this is that the original error didn’t point to this at all.  It talked about a “type not found” error.

I did a bunch of research on the web about it and finally came up with something plausible.  It pointed to the fact that the integrated web server in Visual Studio might be the culprit.

Sure enough… I’m using the integrated web server.  When I created a site in IIS and switched over to that, I was able to run the code successfully.

Update:  Incidently, here’s a link to the article I found that led me to the solution:

http://connect.microsoft.com/VisualStudio/feedback/details/274696/using-custom-identities-in-asp-net-fails-when-using-the-asp-net-developement-server

It appears to be a known issue that Microsoft won’t be addressing anytime soon.

Posted by Microsoft on 6/29/2007 at 3:36 PM
Thank you for your feedback. We are aware of this issue and are not planning to address this in the ASP.NET Development Server for this release. We will consider this issue again in a future release.

The Web Tools Team

Scroll To Top