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 8587273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:31:48+00:00 2026-06-11T22:31:48+00:00

I have a problem implementing forms authentication with an IOC container in my ASP.NET

  • 0

I have a problem implementing forms authentication with an IOC container in my ASP.NET MVC 3 project. We have stored our user information in the database and has a lot of custom properties.

I have an interface of my user definition registrated to the IOC container for development purposes. This interface is given to each controller so the controllers has current user information.

This al works fine until i remove the dummy user registration in the Application_Start

I receive this error:
The current type, …CurrentUserInformation.IUserInformation, is an interface and cannot be constructed. Are you missing a type mapping?

I don’t want to work with a dummy user object because I think this is not the best practice.

Can sombody help me or is there a better way to do this custom authentication?

edit added some code

BaseController

public class BaseController : Controller
{
   private readonly IUserInformation _userInformation;
   public BaseController(IUserInformation userInformation)
   {
       _userInformation = userInformation
   }
}

Bootstrapper Initialize called from Application_Start

public static void Initialise()
{
    var container = BuildUnityContainer();
    DependencyResolver.SetResolver(new UnityDependencyResolver(container));
}

private static IUnityContainer BuildUnityContainer()
{
    var container = new UnityContainer();

    //register all services en repositories

    //here i put my dummy user wich i want to remove
    container.RegisterInstance<IUserInformation>(
    new UserInformation
    {
        UserId = 1,
        ... 
    }); 


    return container;
}
  • 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-06-11T22:31:50+00:00Added an answer on June 11, 2026 at 10:31 pm

    You can use InjectionFactory:

    container.RegisterType<IUserInformation, UserInformation>(
    
        // User information is destroyed when the request ends.
        //   You could use an HttpSessionLifetimeManager as well, if it fits your needs
        new HttpRequestLifetimeManager(), 
    
    
        new InjectionFactory(container => { 
              UserInformation userInfo = // TODO: build your userInformation from custom authentication
              return userInfo;
        })); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add simple Authentication and Authorization to an ASP.NET MVC application. I'm
I'm implementing CAPTCHA in my form submission as per Sanderson's book Pro ASP.NET MVC
I have a ASP.NET MVC site with a CAS server set up as the
We have a strange problem when implementing sessions with ColdFusion in IE6. After login
I'm new to the world of IoC and having a problem with implementing it
I have a problem implementing dropdownchoice in my code. I want to display a
I have been implementing various forms of simple collision detection with varying results. I
I am trying to write an ASP.NET MVC application which is a frontend to
I have been tasked with implementing a WCF service in VB.NET. This WCF service
I have a problem implementing this example in java, tableFilterDemo is a class that

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.